From d93ad2b865cc8cb35f71a54c6c4bcecfc5be4ade Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 3 Apr 2025 13:22:04 +0100 Subject: [PATCH] Add more detail about disabling the servlet --- .../src/main/antora/modules/ROOT/pages/server.adoc | 5 +++++ .../META-INF/additional-spring-configuration-metadata.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc b/spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc index b550edb..a192d13 100644 --- a/spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc +++ b/spring-grpc-docs/src/main/antora/modules/ROOT/pages/server.adoc @@ -87,6 +87,11 @@ Clients can connect to the server using that path, which is what any gRPC client The gRPC server has fewer configuration options when running in a servlet container, as the servlet container is responsible for the network layer. You can still add `ServerBuilderCustomizer` beans to customize the server as it is built, but some features common in the "native" builders are not available and may throw exceptions at runtime. +== Native gRPC Server inside a Servlet Container +The native gRPC server (with netty etc.) will run happily inside a web application, listening on a different port. +If you want to do that in any Spring Boot application, it should be sufficient *not* to include the `grpc-servlet-jakarta` dependency on your classpath. +This dependency is only provided by the `spring-grpc-server-web-spring-boot-starter` (or if you include it explicitly yourself), but if you need to be explicit you can set `spring.grpc.server.servlet.enabled=false` in your application configuration. + [[server-interceptor]] == Server Interceptors diff --git a/spring-grpc-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-grpc-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 773f888..71ca9f4 100644 --- a/spring-grpc-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-grpc-spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -32,7 +32,7 @@ { "name": "spring.grpc.server.servlet.enabled", "type": "java.lang.Boolean", - "description": "Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be forced.", + "description": "Whether to use a servlet server in a servlet-based web application. When the value is false, a native gRPC server will be created as long as one is available, and it will listen on its own port. Should only be needed if the GrpcServlet is on the classpath", "defaultValue": true }, {