zoukankan      html  css  js  c++  java
  • [解决]--java_out: User.proto: User.proto: Cannot generate Java output because the file 's

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

    [解决]--java_out: User.proto: User.proto: Cannot generate Java

    解决方法:

    原因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类的类名
  • 相关阅读:
    C# Brush Color String 互相转换
    WPF Binding ElementName方式无效的解决方法--x:Reference绑定
    WPF动画应用-几何图形扩散动画
    Timer更新UI的合理办法
    员工管理
    EF CodeFirst 实例Demo
    C# 星期相关代码实例
    WPF Canvas实现进度条
    DispatcherTimer 应用实例
    数据库操作命令
  • 原文地址:https://www.cnblogs.com/zhaoxinshanwei/p/6888576.html
Copyright © 2011-2022 走看看