有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何在gRPC中为Java手动生成客户端和服务器代码?

official documentation说明了有关生成客户机和服务器代码的以下内容

Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler protoc with a special gRPC Java plugin. You need to use the proto3 compiler (which supports both proto2 and proto3 syntax) in order to generate gRPC services.

不幸的是,它只是建议使用Maven或Gradle来生成实际的客户机和服务器存根

这一代的实际protoc命令行调用是什么


共 (1) 个答案

  1. # 1 楼答案

    {a1}自述文件谈到了这一点:

    To compile a proto file and generate Java interfaces out of the service definitions:

    $ protoc  plugin=protoc-gen-grpc-java=build/exe/java_plugin/protoc-gen-grpc-java \
       grpc-java_out="$OUTPUT_FILE"  proto_path="$DIR_OF_PROTO_FILE" "$PROTO_FILE"