protoc not generating service stub files

微笑、不失礼 提交于 2019-11-27 21:12:40

The command line you are showing does not enable the grpc plugin. You need to specify an _out argument for the grpc plugin, which enables the plugin and specifies where it should output files. Since the plugin is likely not in your PATH, you also need to tell protoc how to find the plugin with --plugin.

So you need to add two arguments:

--plugin=protoc-gen-grpc-java=path/to/protoc-gen-grpc-java --grpc-java_out=path/to/output/dir

For more info, see the gRPC compiler documentation.

You can add these option to your .proto (base on your language) to generate abstract services:

option cc_generic_services = true;
option java_generic_services = true;
option py_generic_services = true;

You can also add --plugin=EXECUTABLE option in your protoc cmd to use custom code generator plugin to generate code more specific to each system, rather than rely on the "abstract" services. Just like Eric's suggestion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!