Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 views
in Technique[技术] by (71.8m points)

protocol buffers - protoc not generating service stub files

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.

proto file, https://github.com/grpc/grpc-java/blob/master/examples/src/main/proto/hello_world.proto

terminal output,

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: examples

test/io/grpc/examples: helloworld

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

Has anybody else faced this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...