protobuf vs java

生成 java 代码时的警告:

The default outer class name, "Auth", conflicts with a type declared in the proto file and an alternative outer class name is used: "AuthOuterClass". To avoid this warning, please use the java_outer_classname option to specify a different outer class name for the .proto file

原因:

1.Java保存的文件名必须与类名一致;
2.如果文件中只有一个类,文件名必须与类名一致;
3.一个Java文件中只能有一个public类;
4.如果文件中不止一个类,文件名必须与public类名一致;
5.如果文件中不止一个类,而且没有public类,文件名可与任一类名一致。

解决方案:

在.proto文件中添加选项,明确指定生成的java源文件的文件名及公共类名

option java_outer_classname = "AliasName"; 

posted @ 2016-07-06 23:50  RushoutAsia  阅读(513)  评论(0编辑  收藏  举报