-
Notifications
You must be signed in to change notification settings - Fork 88
Spring gRPC Migration from Ecosystem Projects
-
Replace
net.devh:grpc-client-spring-boot-starterwithorg.springframework.boot:spring-boot-starter-grpc-server(for server apps) and/ororg.springframework.boot:spring-boot-starter-grpc-client(for client apps) in your Gradle or Maven build. Replaceorg.springframework.grpc:spring-grpc-testwithorg.springframework.boot:spring-boot-starter-grpc-client-test. You no longer need to import a separate BOM — dependency versions are managed by Spring Boot 4.1.0 itself. -
Classes annotated
@GrpcGlobalServerInterceptorshould now be annotated@Componentand@GlobalServerInterceptorinstead. (Search and replace imports and annotations.) Classes annotated@GrpcGlobalClientInterceptorshould now be annotated@Componentand@GlobalClientInterceptorinstead. (Search and replace imports and annotations.) Search and replacenet.devh.boot.grpc.server.service.GrpcServicewithorg.springframework.grpc.server.service.GrpcService. -
Classes annotated
@GrpcAdvicewith methods annotated@GrpcExceptionHandlershould now be annotated@Componentand implement theGrpcExceptionHandlerinterface instead. -
Search and replace
net.devh.boot.grpc.server.security.interceptors.AuthenticatingServerInterceptor.SECURITY_CONTEXT_KEYwithorg.springframework.grpc.server.security.GrpcSecurity.SECURITY_CONTEXT_KEY. -
You may need to implement an
AuthenticationProcessInterceptorand annotate it with@GlobalServerInterceptor. See Declarative Security with Spring Security. -
If you implement
GrpcAuthenticationReader, you'll need to implementGrpcAuthenticationExtractorinstead. -
In tests that use an in-process server, annotate the test class with
@AutoConfigureTestGrpcTransport(previously@AutoConfigureInProcessTransport). Autowire your stubs directly rather than using the@GrpcClient("inProcess")annotation or thegrpc.server.inProcessNameandgrpc.client.inProcess.addressproperties. If your stubs are not already declared as beans, add a@TestConfigurationclass that declares them (using an autowiredGrpcChannelFactoryif needed). Also add@ImportGrpcClients(on the test class or the@TestConfiguration) to register gRPC stubs as Spring beans — this is now required explicitly. -
In your application properties, replace
grpc.server.portwithspring.grpc.server.port, andgrpc.client.<name>.addresswithspring.grpc.client.channel.<name>.target.