将Spring Boot与gRPC和Protobuf一起使用 [英] Using Spring Boot together with gRPC and Protobuf
本文介绍了将Spring Boot与gRPC和Protobuf一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人将gRPC与Spring Boot一起使用时有任何示例或想法吗?
Anyone having any examples or thoughts using gRPC together with Spring Boot?
推荐答案
如果它仍然与您相关,那么我已经创建了gRPC spring-boot-starter
If it's still relevant for you, I've created gRPC spring-boot-starter here.
grpc-spring-boot-starter 使用 @ GRpcService-enabled bean自动配置并运行嵌入式gRPC服务器.
grpc-spring-boot-starter auto-configures and runs the embedded gRPC server with @GRpcService-enabled beans.
最简单的示例:
@GRpcService(grpcServiceOuterClass = GreeterGrpc.class)
public static class GreeterService implements GreeterGrpc.Greeter {
@Override
public void sayHello(GreeterOuterClass.HelloRequest request, StreamObserver<GreeterOuterClass.HelloReply> responseObserver) {
// omitted
}
}
在项目的README文件中还有一个如何将启动器与Eureka集成的示例.
There is also an example of how to integrate the starter with Eureka in project's README file.
这篇关于将Spring Boot与gRPC和Protobuf一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文