From 4c1ee098f9e1c78f13f497c644c90f744d921053 Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Fri, 7 Feb 2025 12:37:18 -0600 Subject: [PATCH] Add servlet server starter module This adds a starter module that includes the Spring gRPC server starter and the required dependencies ((`spring-boot-starter-web` and `jakarta-grpc-servlet`) to use the servlet container as a gRPC server. Signed-off-by: Chris Bono --- pom.xml | 1 + spring-grpc-dependencies/pom.xml | 10 ++++++ .../antora/modules/ROOT/pages/server.adoc | 18 +++-------- .../pom.xml | 32 +++++++++++++++++++ 4 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 spring-grpc-server-web-spring-boot-starter/pom.xml diff --git a/pom.xml b/pom.xml index ca3567c..4a2a17b 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ spring-grpc-spring-boot-autoconfigure spring-grpc-spring-boot-starter spring-grpc-client-spring-boot-starter + spring-grpc-server-web-spring-boot-starter samples diff --git a/spring-grpc-dependencies/pom.xml b/spring-grpc-dependencies/pom.xml index 174d262..1fa606b 100644 --- a/spring-grpc-dependencies/pom.xml +++ b/spring-grpc-dependencies/pom.xml @@ -75,6 +75,16 @@ spring-grpc-spring-boot-starter ${project.version} + + org.springframework.grpc + spring-grpc-client-spring-boot-starter + ${project.version} + + + org.springframework.grpc + spring-grpc-server-web-spring-boot-starter + ${project.version} + org.springframework.grpc 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 7e0cc3f..231b4b0 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 @@ -59,21 +59,15 @@ dependencies { == Servlet Server Any servlet container can be used to run a gRPC server. -Spring gRPC includes autoconfiguration that configures the server to use the servlet container if it detects that it is in a web application, so all you have to do is include `spring-boot-starter-web` and the `grpc-servlet` dependnecy in your application. +Spring gRPC includes autoconfiguration that configures the server to use the servlet container if it detects that it is in a web application. +Spring gRPC also provides a convenience starter that includes the required dependencies (`spring-boot-starter-web` and the `grpc-servlet-jakarta`) for this scenario. +So all you have to do is include the `spring-boot-starter-web` dependency as follows: [source,xml] ---- - - org.springframework.boot - spring-boot-starter-web - org.springframework.grpc - spring-grpc-spring-boot-starter - - - io.grpc - grpc-servlet-jakarta + spring-grpc-server-web-spring-boot-starter ---- @@ -82,9 +76,7 @@ For Gradle users [source,gradle] ---- dependencies { - implementation "org.springframework.boot:spring-boot-starter-web" - implementation "org.springframework.grpc:spring-grpc-spring-boot-starter" - implementation "io.grpc:grpc-servlet-jakarta" + implementation "org.springframework.grpc:spring-grpc-server-web-spring-boot-starter" } ---- diff --git a/spring-grpc-server-web-spring-boot-starter/pom.xml b/spring-grpc-server-web-spring-boot-starter/pom.xml new file mode 100644 index 0000000..53e65b2 --- /dev/null +++ b/spring-grpc-server-web-spring-boot-starter/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + org.springframework.grpc + spring-grpc + 0.4.0-SNAPSHOT + + spring-grpc-server-web-spring-boot-starter + jar + Spring gRPC Servlet Server Spring Boot Starter + Spring gRPC Servlet Server Spring Boot Starter + + + + org.springframework.grpc + spring-grpc-spring-boot-starter + + + io.grpc + grpc-servlet-jakarta + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot.version} + + + +