首页 > 编程语言 > 详细

[解决]--java_out: User.proto: User.proto: Cannot generate Java output because the file 's

时间:2017-05-22 11:34:50      阅读:671      评论:0      收藏:0      [点我收藏+]

在使用 protocol buffer 的时候,用.proto文件生成代码文件时报错

使用命令

protoc.exe --java_out c:\logs\ User.proto

User.proto文件内容格式如下

message User{                                                                                   
    required string userName = 1[default=""];                                                                               
    required string password = 2[default=""];                                                                               
}                                                                       
使用cmd命令时出现如下错误

--java_out: User.proto: User.proto: Cannot generate Java output because the file
‘s outer class name, "User", matches the name of one of the types declared insid
e it.  Please either rename the type or use the java_outer_classname option to s
pecify a different outer class name for the .proto file.

技术分享

解决方法:

原因User.proto文件名和里面的类名重复,文件名是User 里面内容message User都使用 User

修改User.proto文件名改成不和里面类名重复的就可以了,这里改成UserProtobuff

然后运行protoc.exe --java_out c:\logs\ UserProtobuff.proto 运行成功了。

第二种解决方法:

  在ptoto文件中添加i行

option java_outer_classname="ReservationTypeOuterClass";
来指定生成的java类的类名

[解决]--java_out: User.proto: User.proto: Cannot generate Java output because the file 's

原文:http://www.cnblogs.com/zhaoxinshanwei/p/6888576.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!