码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2017-05-22 12:01:38      阅读:312      评论:0      收藏:0      [点我收藏+]

标签:buffer   java   报错   修改   password   生成   方法   文件中   src   

在使用 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

标签:buffer   java   报错   修改   password   生成   方法   文件中   src   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!