首页 > Windows开发 > 详细

在windows上使用protobuf

时间:2020-10-21 12:13:45      阅读:60      评论:0      收藏:0      [点我收藏+]
一、下载protoc.exe
二、下载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

在windows上使用protobuf

原文:https://blog.51cto.com/332532/2542707

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!