gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 09:36:35 27 4
gpt4 key购买 nike

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 来生成实际的客户端和服务器 stub 。

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

最佳答案

gRPC Java Codegen Plugin for Protobuf Compiler自述文件讨论了这一点:

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"

关于java - 如何在 gRPC 中手动为 Java 生成客户端和服务器代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56435980/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com