在使用 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的更多相关文章

  1. org.apache.hadoop.hive.ql.metadata.HiveException: Internal Error: cannot generate all output rows for a Partition解决

    自己在路径访问明细表开发时,写的sql如下 SELECT guid, sessionid, event['url'] as page, `timestamp` as ts, row_number() ...

  2. 解决 Error: could not open `C:\Program Files\Java\jre7\lib\i386\jvm.cfg'

    解决 Error: could not open `C:\Program Files\Java\jre7\lib\i386\jvm.cfg' 重装JDK后,因为没有装在以前的目录,运行java命令后报 ...

  3. 解决N个人过桥时间最短问题(Java版本)

    [问题描述] n个人要晚上过桥,在任何时候最多两个人一组过桥,每组要有一只手电筒.在这n个人中只有一个手电筒能用,因此要安排以某种往返的方式来返还手电筒,使更多的人可以过桥.   注意:每个人的过桥速 ...

  4. 解决mac os x下 tomcat启动报 java.net.BindException: Permission denied <null>:80 错误

    我在mac os x上启动tomcat的时候,报 java.net.BindException: Permission denied <null>:80,java.net.BindExce ...

  5. 解决String TestContext下使用junit4抛出异常(java.lang.NoClassDefFoundError)的问题

    Spring版本2.5.5,JUnit 版本 4.8.1,使用了 Spring TestContext 的 SpringJUnit4ClassRunner.一直使用这个版本的JUnit,在写简单的测试 ...

  6. Cloud9:解决ThinkPHP在C9上运行时连接数据库时报错"No such file or directory"的问题

    昨天尝试在c9上部署了一个ThinkPHP用于开发,但是当试图连接数据库时却出现了这样的问题.经过查找资料发现此问题是由于没有找到mysql.sock这个文件造成的(这个东西估计是mysql的连接线程 ...

  7. 解决Junit单元测试 找不到类 ----指定Java Build Path

    做junit 单元测试时,发现怎么执行都是以前编译过得代码. 最后找到原因了, src/test/java 编译完的.class路径是 Default output folder Default ou ...

  8. 异常-----springmvc + ajaxfileupload解决ajax不能异步上传图片的问题。java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to org.springframework.web.multipart.

    说明这个问题产生的原因主要是form表单上传图片的时候必须是Content-Type:"multipart/form-data,这种格式的,但是ajax在页面不刷新的情况下去加载的时候只会把 ...

  9. android开发解决Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: c.....

    网上常见的方法我都试过,都没能解决,偶然看到的一个方法解决了,在这了记录一下. 在App目录下的build.gradle的android{ ...  ....}中添加如下代码,即可解决.(xx.xx. ...

随机推荐

  1. 腾讯高性能RPC开发框架Tars实现服务治理(微服务)

    Github:https://github.com/Tencent/Tars 1. 介绍 Tars是基于名字服务使用Tars协议的高性能RPC开发框架,同时配套一体化的服务治理平台,帮助个人或者企业快 ...

  2. Bootstrap-Plugin:附加导航(Affix)插件

    ylbtech-Bootstrap-Plugin:附加导航(Affix)插件 1.返回顶部 1. Bootstrap 附加导航(Affix)插件 附加导航(Affix)插件允许某个 <div&g ...

  3. Linux(Centos)安装配置SVN服务器

    1. 安装SVN服务器: 检查是否已安装 # rpm -qa subversion 安装SVN服务器 # yum install httpd httpd-devel subversion mod_da ...

  4. c#静态构造函数与构造函数

    构造函数这个概念,在我们刚开始学习编程语言的时候,就被老师一遍一遍的教着.亲,现在你还记得静态构造函数的适用场景吗?如果没有,那么我们一起来复习一下吧. 静态构造函数是在构造函数方法前面添加了stat ...

  5. 安装Android studio出现'tools.jar' seems to be not in Android Studio classpath......的解决方法

    安装Android studio出现'tools.jar' seems to be not in Android Studio classpath......的解决方法 原创 2015年07月31日 ...

  6. mysql总结(三)

    select distinct * from 表名where ...group by ...having ...order by ...limit ... 关系的问题(1)是什么样的对应关系(2)存储 ...

  7. 在ubuntu14.04上搭建OpenVPN服务

    简介 在连接了不可信的网络环境后,让手机或者计算机安全的访问互联网,使用虚拟专用网络(Virtual Private Network,VPN)是一个解决办法.OpenVPN是一个SSL VPN完整解决 ...

  8. IIS 禁止访问:在 Web 服务器上已拒绝目录列表

    webconfig <configuration> <system.webServer> <directoryBrowse enabled="true" ...

  9. java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus

    solution Step: 1.In the classpath tab, be sure to add the wlclient.jar file located here \wlserver_1 ...

  10. tr th td

    <table>     <caption></caption>     <thead>         <tr>             & ...