定义对应的.proto类型文件
syntax ="proto3";
//要生成的包名
option java_package = "com.example.demo.proto";
//要生成的 类名
option java_outer_classname = "Proto";
message Collections{
repeated User users = 1 ;
}
message User {
int32 id = 1;
Position pos = 2;
int32 fraction =3;
int32 size = 4;
}
message Position {
float x = 1;
float y = 2;
}
下载工具 proto.exe
链接:https://pan.baidu.com/s/1rB33kKVbyqAPp-jyoAnDNg
提取码:n172
解压文件 拿到proto.exe
执行:
./protoc.exe --java_out=./ User.proto
# protoc.exe路径
# --java_out 要输出到哪个目录
# User.proto 要编译的proto文件