在使用 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. [题解] [NOIP2008] 双栈排序——关系的冲突至图论解法

    Problem 题目描述 Tom最近在研究一个有趣的排序问题.如图所示,通过2个栈S1和S2,Tom希望借助以下4种操作实现将输入序列升序排序. 操作a 如果输入序列不为空,将第一个元素压入栈S1 操 ...

  2. (转)SqlServer为大数据量表建索引

    本文转载自:http://blog.csdn.net/iangujun/article/details/8136764 之前从没有用SqlServer数据库处理过大数据量的表,都是用Oracle,然后 ...

  3. linux上安装Qt4.8.6+QtCreator4.0.3

    一.Qt简介 Qt是1991年奇趣科技开发的一个跨平台的C++图形用户界面应用程序框架.它提供给应用程序开发者建立艺术级的图形用户界面所需的所有功能.Qt很容易扩展,并且允许真正地组件编程. 准备工作 ...

  4. https请求失败,解决方法

    把请求头中 Content-Type 属性去掉就可以了

  5. mysql-3 数据表的创建、增删改查

    1.创建数据表 通用语法:CREATE TABLE table_name (column_name column_type); CREATE TABLE IF NOT EXISTS `csj_tbl` ...

  6. Spring boot with Apache Hive

      5.29.1. Maven <dependency> <groupId>org.springframework.boot</groupId> <artif ...

  7. 传统项目利用Hystrix实现热点接口的服务隔离

    这段时间接了个需求,需要在我目前负责的数据系统上加个接口,主要是实现用户行为的记录.前端对接的项目主要有公司的PC,WAP,WEIXIN,APP等,每个端大概有两台左右的负载.因为目前我的这个项目主要 ...

  8. HyberLedger Fabric学习(4)-chaincode学习(操作人员)

    参考:http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4noah.html chaincode也能被称作“智能合约”,一般情况下 ...

  9. tomcat 域名直接访问默认工程,而不添加项目路径

    <Engine name="Catalina" defaultHost="xx.xx.xx.xx"> <!--For clustering, ...

  10. 新手C#string类常用函数的学习2018.08.04

    ToLower()用于将字符串变为小写,注意字符串的不可变特性,需要重新赋值给另一个字符串变量. s = s.ToLower();//字符串具有不可变性,转换后需要重新赋值,不可仅有s.ToLower ...