protobuf使用说明

1..proto文件为要生成.java文件的模板文件,其中包含名称空间、文件名等信息
2.cmd中进入当前目录D:\JAVA\protoc-2.5.0-win32
3.运行 protoc.exe –java_out=. SubscribeReq.proto 将在当前文件夹下生成对应的.java文件

SubscribeReq.proto

package netty;option java_package="myprotobuf";option java_outer_classname="SubscribeReqProto";message SubscribeReq{    required int32 subReqID=1;    required string userName=2;    required string productName=3;    repeated string address=4;}

SubscribeReq.proto

package netty;option java_package="myprotobuf";option java_outer_classname="SubscribeRespProto";message SubscribeResp{    required int32 subReqID=1;    required int32 respCode=2;    required string desc=3;}