协议不生成服务存根文件 [英] protoc not generating service stub files

查看:110
本文介绍了协议不生成服务存根文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始玩Google Proto.当我尝试编译proto-java示例中存在的proto文件时,它不会生成任何grpc文件.

I have just started playing with google proto. When I try to compile proto file present in proto-java example, it does not generate any grpc file.

原始文件, https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/hello_world.proto

终端输出

rsonkhla @ raman-OptiPlex-9020:〜/sandbox/grpc-java/examples $协议 --version libprotoc 3.0.0 rsonkhla @ raman-OptiPlex-9020:〜/sandbox/grpc-java/examples $协议 --java_out = test/-I ../../grpc-java/examples ../../grpc-java/examples/src/main/proto/hello_world.proto rsonkhla @ raman-OptiPlex-9020:〜/sandbox/grpc-java/examples $ ls -R测试/ 测试/:io

rsonkhla@raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc --version libprotoc 3.0.0 rsonkhla@raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ protoc --java_out=test/ -I../../grpc-java/examples ../../grpc-java/examples/src/main/proto/hello_world.proto rsonkhla@raman-OptiPlex-9020:~/sandbox/grpc-java/examples$ ls -R test/ test/: io

test/io:grpc

test/io: grpc

test/io/grpc:示例

test/io/grpc: examples

test/io/grpc/examples:helloworld

test/io/grpc/examples: helloworld

test/io/grpc/examples/helloworld:HelloRequest.java
HelloResponse.java HelloWorldProto.java HelloRequestOrBuilder.java HelloResponseOrBuilder.java

test/io/grpc/examples/helloworld: HelloRequest.java
HelloResponse.java HelloWorldProto.java HelloRequestOrBuilder.java HelloResponseOrBuilder.java

还有其他人遇到过这个问题吗?

Has anybody else faced this issue?

推荐答案

您显示的命令行未启用grpc插件.您需要为grpc插件指定一个_out参数,该参数启用插件并指定输出文件的位置.由于该插件可能不在您的PATH中,因此您还需要告诉protoc如何使用--plugin查找该插件.

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

有关更多信息,请参见gRPC 编译器文档.

For more info, see the gRPC compiler documentation.

这篇关于协议不生成服务存根文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆