在使用protobuf生成相应类文件如java文件的时候需要指定proto的版本,

如:

syntax = "proto2";

package my_package;

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

这是proto2的描述文件,如果使用proto3的话需要指定:syntax = "proto3";

 原文来自:http://www.cnblogs.com/gifisan/p/5976208.html 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-11-28
  • 2021-10-26
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-05-24
  • 2021-05-25
  • 2022-01-18
相关资源
相似解决方案