This project provides out-of-the-box, highly scalable Spring Boot starters for the cutting-edge ecosystem of gRPC.
Make the integration of gRPC with Spring Boot feel seamless and native.
Core:
- Dependencies management for gRPC related libraries
- gRPC server autoconfiguration
- gRPC client autoconfiguration
Extensions:
- JSON transcoder: A single codebase to simultaneously support both gRPC and HTTP/JSON.
- Protobuf validation: Protobuf message validation implemented by protovalidate/protoc-gen-validate.
- Metric: Spring Boot Actuator integration with gRPC service.
- Tracing: Spring Boot Actuator integration with gRPC server and client.
- Testing: Integration with
SpringBootTest
.
implementation(platform("io.github.danielliu1123:grpc-starter-dependencies:3.2.5"))
implementation("io.github.danielliu1123:grpc-boot-starter")
From version 3.2.0, the groupId of the project has been changed to
io.github.danielliu1123
fromcom.freemanan
.
@SpringBootApplication
public class SimpleApp extends SimpleServiceGrpc.SimpleServiceImplBase {
public static void main(String[] args) {
new SpringApplicationBuilder(SimpleApp.class)
.properties("grpc.client.base-packages=io.grpc")
.properties("grpc.client.authority=127.0.0.1:9090")
.run(args);
}
@Override
public void unaryRpc(SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) {
SimpleResponse response = SimpleResponse.newBuilder()
.setResponseMessage("Hello " + request.getRequestMessage())
.build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
@Bean
ApplicationRunner runner(SimpleServiceGrpc.SimpleServiceBlockingStub stub) {
return args -> {
SimpleResponse response = stub.unaryRpc(SimpleRequest.newBuilder().setRequestMessage("World!").build());
System.out.println(response.getResponseMessage());
};
}
}
See the example project。
Mainly maintain the following versions:
-
3.x
Based on Spring Boot 3, baseline is JDK 17, the corresponding branch is main.
3.x version is kept in sync with Spring Boot 3, if you are using Spring Boot 3.2.x, then
grpc-boot-starter
3.2.5 should be used.Spring Boot grpc-boot-starter 3.1.x 3.1.8 3.2.x 3.2.5 -
2.x
Based on Spring Boot 2, baseline is JDK 8, the corresponding branch is 2.x
Spring Boot grpc-boot-starter 2.x 2.1.6
The MIT License.