標籤: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