二、下载protoc-gen-grpc-java-1.28.1-windows-x86_64.exe
三、编写helloworld.proto文件
内容:
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.yuhang.protobuf";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user‘s name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
四、在cmd执行以下命令
1)D:\work2020\proto\protoc-3.13.0-win64\bin\protoc.exe --plugin=protoc-gen-grpc-java=D:\work2020\proto\protoc-gen-grpc-java-1.28.1-windows-x86_64.exe --grpc-java_out=. helloworld.proto
获得:GreeterGrpc
2)D:\work2020\proto\protoc-3.13.0-win64\bin\protoc.exe --java_out=. helloworld.proto
获得:
HelloReply
HelloReplyOrBuilder
HelloRequest
HelloRequestOrBuilder
HelloWorldProto