From 6690c79a2dfa95f93f875a88b2c0326b369642a9 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Thu, 22 May 2025 16:22:29 -0400 Subject: [PATCH] Migrate server-webmvc properties to new namespace See gh-3647 --- .../spring-cloud-gateway-server-webmvc/starter.adoc | 2 +- .../GatewayMvcClassPathWarningAutoConfiguration.java | 3 ++- .../server/mvc/GatewayServerMvcAutoConfiguration.java | 2 +- .../gateway/server/mvc/VanillaRouterFunctionTests.java | 2 +- .../application-functionhandlerconfigtests.yml | 2 +- ...lication-propertiesbeandefinitionregistrartests.yml | 2 +- .../resources/application-streamhandlerconfigtests.yml | 2 +- .../resources/application-stripprefixstaticport.yml | 2 +- ...lication-weightrequestpredicateintegrationtests.yml | 2 +- .../additional-spring-configuration-metadata.json | 10 ---------- 10 files changed, 10 insertions(+), 19 deletions(-) diff --git a/docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/starter.adoc b/docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/starter.adoc index 6d3b7bd8..d8f759ce 100644 --- a/docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/starter.adoc +++ b/docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/starter.adoc @@ -5,7 +5,7 @@ To include Spring Cloud Gateway Server Web MVC in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-gateway-server-webmvc`. See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train. -If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.mvc.enabled=false`. +If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.server.webmvc.enabled=false`. IMPORTANT: Spring Cloud Gateway Server MVC is built on https://spring.io/projects/spring-boot#learn[Spring Boot] and https://docs.spring.io/spring-framework/reference/web/webmvc-functional.html[Spring WebMvc.fn]. As a consequence, many of the asynchronous or reactive libraries may not apply when you use Spring Cloud Gateway Server MVC. diff --git a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayMvcClassPathWarningAutoConfiguration.java b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayMvcClassPathWarningAutoConfiguration.java index 4fef7bc7..21173cf9 100644 --- a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayMvcClassPathWarningAutoConfiguration.java +++ b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayMvcClassPathWarningAutoConfiguration.java @@ -22,11 +22,12 @@ import org.apache.commons.logging.LogFactory; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.gateway.server.mvc.config.GatewayMvcProperties; import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) @AutoConfigureBefore(GatewayServerMvcAutoConfiguration.class) -@ConditionalOnProperty(name = "spring.cloud.gateway.mvc.enabled", matchIfMissing = true) +@ConditionalOnProperty(name = GatewayMvcProperties.PREFIX + ".enabled", matchIfMissing = true) public class GatewayMvcClassPathWarningAutoConfiguration { private static final Log log = LogFactory.getLog(GatewayMvcClassPathWarningAutoConfiguration.class); diff --git a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayServerMvcAutoConfiguration.java b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayServerMvcAutoConfiguration.java index 37cd5245..2aecabe1 100644 --- a/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayServerMvcAutoConfiguration.java +++ b/spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayServerMvcAutoConfiguration.java @@ -78,7 +78,7 @@ import org.springframework.web.client.RestClient; @AutoConfiguration(after = { HttpClientAutoConfiguration.class, RestTemplateAutoConfiguration.class, RestClientAutoConfiguration.class, FilterAutoConfiguration.class, HandlerFunctionAutoConfiguration.class, PredicateAutoConfiguration.class }) -@ConditionalOnProperty(name = "spring.cloud.gateway.mvc.enabled", matchIfMissing = true) +@ConditionalOnProperty(name = GatewayMvcProperties.PREFIX + ".enabled", matchIfMissing = true) @Import(GatewayMvcPropertiesBeanDefinitionRegistrar.class) @ImportRuntimeHints(GatewayMvcAotRuntimeHintsRegistrar.class) public class GatewayServerMvcAutoConfiguration { diff --git a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/VanillaRouterFunctionTests.java b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/VanillaRouterFunctionTests.java index fd96c938..81d1128c 100644 --- a/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/VanillaRouterFunctionTests.java +++ b/spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/VanillaRouterFunctionTests.java @@ -43,7 +43,7 @@ import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFuncti import static org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates.host; @SuppressWarnings("unchecked") -@SpringBootTest(properties = { "spring.cloud.gateway.mvc.http-client.type=jdk" }, +@SpringBootTest(properties = { "spring.http.client.factory=jdk" }, webEnvironment = WebEnvironment.RANDOM_PORT) @ContextConfiguration(initializers = HttpbinTestcontainers.class) public class VanillaRouterFunctionTests { diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml index c7430ca4..847e7057 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml @@ -1,4 +1,4 @@ -spring.cloud.gateway.mvc: +spring.cloud.gateway.server.webmvc: routesMap: testsimplefunction: uri: fn:upper diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-propertiesbeandefinitionregistrartests.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-propertiesbeandefinitionregistrartests.yml index a91fe14d..cd55ac63 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-propertiesbeandefinitionregistrartests.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-propertiesbeandefinitionregistrartests.yml @@ -1,4 +1,4 @@ -spring.cloud.gateway.mvc: +spring.cloud.gateway.server.webmvc: routesMap: route1: uri: https://example1.com diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-streamhandlerconfigtests.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-streamhandlerconfigtests.yml index 3e97fc80..00cfc6b9 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-streamhandlerconfigtests.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-streamhandlerconfigtests.yml @@ -1,4 +1,4 @@ -spring.cloud.gateway.mvc: +spring.cloud.gateway.server.webmvc: routesMap: testsimplestream: uri: stream:hello-out-0 diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-stripprefixstaticport.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-stripprefixstaticport.yml index c27795c3..184cfee5 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-stripprefixstaticport.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-stripprefixstaticport.yml @@ -1,5 +1,5 @@ strip.prefix.static.uri: http://${httpbin.host}:${httpbin.port} -spring.cloud.gateway.mvc: +spring.cloud.gateway.server.webmvc: routes: - id: strip_prefix_static_port_config uri: ${strip.prefix.static.uri} diff --git a/spring-cloud-gateway-server-mvc/src/test/resources/application-weightrequestpredicateintegrationtests.yml b/spring-cloud-gateway-server-mvc/src/test/resources/application-weightrequestpredicateintegrationtests.yml index 69d927b8..f4dc97ad 100644 --- a/spring-cloud-gateway-server-mvc/src/test/resources/application-weightrequestpredicateintegrationtests.yml +++ b/spring-cloud-gateway-server-mvc/src/test/resources/application-weightrequestpredicateintegrationtests.yml @@ -1,4 +1,4 @@ -spring.cloud.gateway.mvc: +spring.cloud.gateway.server.webmvc: routes: - id: weight_high_test uri: https://examplel1.com diff --git a/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 1a646d71..13464a13 100644 --- a/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-cloud-gateway-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -1966,16 +1966,6 @@ "since": "4.3.0" } }, - { - "name": "spring.cloud.gateway.mvc.routes", - "type": "java.util.List", - "description": "List of Routes.", - "deprecated": true, - "deprecation": { - "replacement": "spring.cloud.gateway.server.webflux.mvc.routes", - "since": "4.3.0" - } - }, { "name": "spring.cloud.gateway.observability.enabled", "type": "java.lang.Boolean",