天道酬勤,学无止境

google-protocol-buffer

如何为 gRPC 生成的 Java 代码实现 com.google.protobuf.BlockingRpcChannel?(How to implement com.google.protobuf.BlockingRpcChannel for gRPC generated Java code?)

问题 我最近使用了一个代表 gRPC 服务的 proto 文件并从中生成了 Java 代码。 但是,所有接口都需要一个 com.google.protobuf.BlockingRpcChannel ,我不知道如何创建它。 当我查看示例时,我看到人们使用 io.grpc.ManagedChannel 但那是因为生成的 Java 代码使用了该类型。 我不确定是不是因为我使用的是特定版本的 protobuf 还是什么? public static BlockingInterface newBlockingStub(com.google.protobuf.BlockingRpcChannel channel) { return new BlockingStub(channel); } 以下是我所看到的示例 https://www.programcreek.com/java-api-examples/?api=io.grpc.ManagedChannel 在本教程中,它建议执行以下操作,但接口不对齐。 我有一个 BlockRpcChannel,在示例中他们可以使用 ManagedChannel。 生成的 java 代码不会接受 ManagedChannel [![https://grpc.io/docs/tutorials/basic/java/][1]][1] 在我的原型中

2021-10-26 14:16:44    分类:技术分享    grpc-java   google-protocol-buffer

方法 emptyIntList() 未定义(The method emptyIntList() is undefined)

问题 我是Google Protobuf 的新手。 尝试使用下面的student.proto文件玩它。 syntax = "proto3"; package rld; option java_package = "com.rld"; option java_outer_classname = "StudentDTO"; message Student { string name = 1; int32 roll = 2; repeated int32 mark = 3; //Marks in various subjects } message StudentDatabase { repeated Student student = 1; } 然后我尝试使用下面的 Protobuf 编译器命令编译它。 从这里,我下载了编译器。 protoc -I=. --java_out=. ./student.proto 它编译成功并生成StudentDTO.java ,但有错误。 类中有两个方法“ emptyIntList() ”和“ newIntList() ”,但它们没有被定义。 现在我的问题是如何解决这些错误或者我错过了什么? 回答1 作为新手,我似乎忘记在更新Protobuf Compiler时更新Google Protobuf Runtime 。 两个版本必须匹配。 这里有2个解决方案

2021-10-24 14:54:06    分类:技术分享    protobuf-java   google-protocol-buffer

如何编译 google-fhir proto 文件(How to compile google-fhir proto files)

问题 查看 google-fhir 的自述文件,它说运行bazel build ,它可以工作,但是没有编译任何协议文件。 运行protoc --proto_path=. --java_out=. proto/stu3/resources.proto protoc --proto_path=. --java_out=. proto/stu3/resources.proto protoc --proto_path=. --java_out=. proto/stu3/resources.proto返回一堆关于未找到其他 proto 的错误。 这会倒退直到'descriptor.proto',它不是文件夹中的原型。 该目录中的任何协议文件都不会手动编译为 java 文件。 *另一方面,我能够从其他来源获取其他示例原型并成功编译它们。 更新 从 google-fhir 基本目录运行命令protoc --proto_path=proto/stu3/ --java_out=target proto/stu3/resources.proto返回以下输出: ~/fhir-master$ protoc --proto_path=proto/stu3/ --java_out=target proto/stu3/resources.proto proto/stu3/annotations.proto

2021-10-22 17:56:05    分类:技术分享    java   protocol-buffers   bazel   hl7-fhir   google-protocol-buffer

The method emptyIntList() is undefined

I am new to Google Protobuf. Tried to play with it using below student.proto file. syntax = "proto3"; package rld; option java_package = "com.rld"; option java_outer_classname = "StudentDTO"; message Student { string name = 1; int32 roll = 2; repeated int32 mark = 3; //Marks in various subjects } message StudentDatabase { repeated Student student = 1; } Then I tried to compile it using below Protobuf compiler command. From here, I downloaded the compiler. protoc -I=. --java_out=. ./student.proto It compiled successfully and generated StudentDTO.java, but with errors. There are two methods

2021-10-01 11:08:56    分类:问答    protobuf-java   google-protocol-buffer

How to implement com.google.protobuf.BlockingRpcChannel for gRPC generated Java code?

I recently took a proto file representing a gRPC service and generated Java code from it. However, all the interfaces expect a com.google.protobuf.BlockingRpcChannel and I don't have any idea on how to create it. When I look at example, I see people using io.grpc.ManagedChannel but that is because the generated Java code used that type instead. I'm not sure if it's because i'm using a specific version of protobuf or what? public static BlockingInterface newBlockingStub(com.google.protobuf.BlockingRpcChannel channel) { return new BlockingStub(channel); } Here are examples of what i've seen

2021-09-07 15:51:52    分类:问答    grpc-java   google-protocol-buffer

How to compile google-fhir proto files

Looking at the readme for google-fhir it says to run bazel build, which works, however none of the protocol files have been compiled. Running protoc --proto_path=. --java_out=. proto/stu3/resources.proto returns a bunch of error about other protos not being found. This goes backwards until 'descriptor.proto' which is not a proto in the folder. None of the protocol files in that directory will manually compile into java files. *On another note, I was able to take other example protos from other sources and compile those successfully. UPDATE Running the command protoc --proto_path=proto/stu3/ -

2021-07-02 06:31:07    分类:问答    java   protocol-buffers   bazel   hl7-fhir   google-protocol-buffer