[Fix]--java_out:user.proto:user.proto:cannot generate Java output because the file ' s

Source: Internet
Author: User

Generate code files with a. proto file when using protocol buffer times wrong

Using commands

Protoc.exe--java_out C:\logs\ User.proto

User.proto file content format is as follows

Message user{    require D string userName = 1[default= ""];                 & nbsp;                                                                   Required String password = 2[ default= ""];                                                                                  }                            The following error occurred while using the cmd command

--java_out:user.proto:user.proto:cannot generate Java output because the file
' s outer class name, ' User ', matches the name of the one of the types declared Insid
E it. Either rename the type or use the Java_outer_classname option to s
Pecify a different outer class name for the. Proto file.

Workaround:

Cause User.proto file name and the class name inside duplicate, the file name is user inside the content message user uses user

Modify the User.proto file name to not and the inside of the class name is repeated, it is changed to Userprotobuff

Then run Protoc.exe--java_out c:\logs\ Userprotobuff.proto run successfully.

Second workaround:

Add an I line to the Ptoto file

Option java_outer_classname="Reservationtypeouterclass";
To specify the class name of the generated Java class

[Fix]--java_out:user.proto:user.proto:cannot generate Java output because the file ' s

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.