Use protobuf on windows

1. Download protoc.exe
2. Download protoc-gen-grpc-java-1.28.1-windows-x86_64.exe
3. Write the
content of the helloworld.proto file :
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

Guess you like

Origin blog.51cto.com/332532/2542707