From 3becdc7d47f5c0a9478d1a734f4ee94f84a1e7bd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 20 Nov 2025 11:01:38 +0000 Subject: [PATCH] Move server.error properties to spring.web.error Closes gh-48201 --- .../boot/autoconfigure/web/WebProperties.java | 8 +++ .../META-INF/spring-devtools.properties | 3 + .../modules/how-to/pages/spring-mvc.adoc | 2 +- .../modules/reference/pages/web/reactive.adoc | 2 +- .../modules/reference/pages/web/servlet.adoc | 2 +- .../AbstractWebEndpointIntegrationTests.java | 2 +- .../LocalDevToolsAutoConfigurationTests.java | 3 +- .../TomcatWebServerConfiguration.java | 7 ++- .../TomcatWebServerFactoryCustomizer.java | 8 ++- ...TomcatWebServerFactoryCustomizerTests.java | 5 +- .../autoconfigure/ServerProperties.java | 8 --- ...itional-spring-configuration-metadata.json | 49 ++++++++++++--- .../META-INF/spring-devtools.properties | 3 - .../error/ErrorWebFluxAutoConfiguration.java | 11 +--- ...orWebExceptionHandlerIntegrationTests.java | 33 +++++----- .../MockMvcAutoConfiguration.java | 3 +- .../actuate/web/ManagementErrorEndpoint.java | 2 +- ...bMvcEndpointChildContextConfiguration.java | 14 ++--- .../error/BasicErrorController.java | 2 +- .../error/ErrorMvcAutoConfiguration.java | 22 ++++--- ...dContextConfigurationIntegrationTests.java | 7 ++- ...asicErrorControllerDirectMockMvcTests.java | 2 +- .../BasicErrorControllerIntegrationTests.java | 60 +++++++++---------- .../BasicErrorControllerMockMvcTests.java | 2 +- .../DefaultErrorViewIntegrationTests.java | 2 +- ...ctuatorCustomSecurityApplicationTests.java | 2 +- ...mpleActuatorExtensionApplicationTests.java | 2 +- .../ui/SampleActuatorUiApplicationTests.java | 2 +- .../application-endpoints.properties | 2 +- .../CustomContextPathErrorPageTests.java | 2 +- ...textPathUnauthenticatedErrorPageTests.java | 2 +- .../CustomServletPathErrorPageTests.java | 2 +- ...vletPathUnauthenticatedErrorPageTests.java | 2 +- .../smoketest/web/secure/ErrorPageTests.java | 2 +- .../web/secure/NoSessionErrorPageTests.java | 2 +- .../secure/UnauthenticatedErrorPageTests.java | 2 +- ...pleWebFluxApplicationIntegrationTests.java | 2 +- 37 files changed, 161 insertions(+), 125 deletions(-) diff --git a/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java b/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java index 33a0a14553e..cae4d46215f 100644 --- a/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java +++ b/core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebProperties.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit; import org.jspecify.annotations.Nullable; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.convert.DurationUnit; import org.springframework.http.CacheControl; @@ -50,6 +51,9 @@ public class WebProperties { private final Resources resources = new Resources(); + @NestedConfigurationProperty + private final ErrorProperties error = new ErrorProperties(); + public @Nullable Locale getLocale() { return this.locale; } @@ -66,6 +70,10 @@ public class WebProperties { this.localeResolver = localeResolver; } + public ErrorProperties getError() { + return this.error; + } + public Resources getResources() { return this.resources; } diff --git a/core/spring-boot-autoconfigure/src/main/resources/META-INF/spring-devtools.properties b/core/spring-boot-autoconfigure/src/main/resources/META-INF/spring-devtools.properties index 9d490e918b2..b672b56fea3 100644 --- a/core/spring-boot-autoconfigure/src/main/resources/META-INF/spring-devtools.properties +++ b/core/spring-boot-autoconfigure/src/main/resources/META-INF/spring-devtools.properties @@ -1,3 +1,6 @@ defaults.spring.template.provider.cache=false +defaults.spring.web.error.include-binding-errors=always +defaults.spring.web.error.include-message=always +defaults.spring.web.error.include-stacktrace=always defaults.spring.web.resources.cache.period=0 defaults.spring.web.resources.chain.cache=false diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc index 084eea90aaf..27dbe7198f6 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/how-to/pages/spring-mvc.adoc @@ -247,7 +247,7 @@ For more detail, see the following sections: Spring Boot installs a '`whitelabel`' error page that you see in a browser client if you encounter a server error (machine clients consuming JSON and other media types should see a sensible response with the right error code). -NOTE: Set `server.error.whitelabel.enabled=false` to switch the default error page off. +NOTE: Set configprop:spring.web.error.whitelabel.enabled[] to `false` to switch the default error page off. Doing so restores the default of the servlet container that you are using. Note that Spring Boot still tries to resolve the error view, so you should probably add your own error page rather than disabling it completely. diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/reactive.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/reactive.adoc index 92736d84d72..5cf29be89b1 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/reactive.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/reactive.adoc @@ -325,7 +325,7 @@ Usually, you would define the properties in your `application.properties` or `ap Common server settings include: * Network settings: Listen port for incoming HTTP requests (`server.port`), interface address to bind to (`server.address`), and so on. -* Error management: Location of the error page (`server.error.path`) and so on. +* Error management: Location of the error page (configprop:spring.web.error.path[]) and so on. * xref:how-to:webserver.adoc#howto.webserver.configure-ssl[SSL] * xref:how-to:webserver.adoc#howto.webserver.enable-response-compression[HTTP compression] diff --git a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc index e2aeb9e119c..dff82454b06 100644 --- a/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc +++ b/documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/web/servlet.adoc @@ -636,7 +636,7 @@ Common server settings include: * Network settings: Listen port for incoming HTTP requests (`server.port`), interface address to bind to (`server.address`), and so on. * Session settings: Whether the session is persistent (`server.servlet.session.persistent`), session timeout (`server.servlet.session.timeout`), location of session data (`server.servlet.session.store-dir`), and session-cookie configuration (`server.servlet.session.cookie.*`). -* Error management: Location of the error page (`server.error.path`) and so on. +* Error management: Location of the error page (configprop:spring.web.error.path[]) and so on. * xref:how-to:webserver.adoc#howto.webserver.configure-ssl[SSL] * xref:how-to:webserver.adoc#howto.webserver.enable-response-compression[HTTP compression] diff --git a/integration-test/spring-boot-actuator-integration-tests/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/integration-test/spring-boot-actuator-integration-tests/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index 16152ab827f..87f74fc7b81 100644 --- a/integration-test/spring-boot-actuator-integration-tests/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/integration-test/spring-boot-actuator-integration-tests/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -706,7 +706,7 @@ public abstract class AbstractWebEndpointIntegrationTests properties = new HashMap<>(); properties.put("endpointPath", endpointPath); - properties.put("server.error.include-message", "always"); + properties.put("spring.web.error.include-message", "always"); applicationContext.getEnvironment().getPropertySources().addLast(new MapPropertySource("test", properties)); applicationContext.refresh(); try { diff --git a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java index 6d5ac1db909..1c6ebe2a4dc 100644 --- a/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java +++ b/module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java @@ -286,8 +286,7 @@ class LocalDevToolsAutoConfigurationTests { } @Configuration(proxyBeanMethods = false) - @Import({ TomcatServletWebServerAutoConfiguration.class, LocalDevToolsAutoConfiguration.class, - WebProperties.class }) + @Import({ TomcatServletWebServerAutoConfiguration.class, LocalDevToolsAutoConfiguration.class }) static class WebResourcesConfig { } diff --git a/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerConfiguration.java b/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerConfiguration.java index 7bdc38b564a..5e1ba7bb4e0 100644 --- a/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerConfiguration.java +++ b/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerConfiguration.java @@ -21,6 +21,8 @@ import org.apache.tomcat.websocket.server.WsSci; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnNotWarDeployment; import org.springframework.boot.autoconfigure.condition.ConditionalOnThreading; +import org.springframework.boot.autoconfigure.web.WebProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.thread.Threading; import org.springframework.boot.tomcat.autoconfigure.reactive.TomcatReactiveWebServerAutoConfiguration; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; @@ -39,12 +41,13 @@ import org.springframework.core.env.Environment; */ @ConditionalOnNotWarDeployment @Configuration(proxyBeanMethods = false) +@EnableConfigurationProperties(WebProperties.class) public class TomcatWebServerConfiguration { @Bean TomcatWebServerFactoryCustomizer tomcatWebServerFactoryCustomizer(Environment environment, - ServerProperties serverProperties, TomcatServerProperties tomcatProperties) { - return new TomcatWebServerFactoryCustomizer(environment, serverProperties, tomcatProperties); + ServerProperties serverProperties, TomcatServerProperties tomcatProperties, WebProperties webProperties) { + return new TomcatWebServerFactoryCustomizer(environment, serverProperties, tomcatProperties, webProperties); } @Bean diff --git a/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizer.java b/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizer.java index 79ed471fd4a..e14b4b57c38 100644 --- a/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizer.java +++ b/module/spring-boot-tomcat/src/main/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizer.java @@ -34,6 +34,7 @@ import org.apache.coyote.http2.Http2Protocol; import org.springframework.boot.autoconfigure.web.ErrorProperties; import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeAttribute; +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.cloud.CloudPlatform; import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.tomcat.ConfigurableTomcatWebServerFactory; @@ -77,11 +78,14 @@ public class TomcatWebServerFactoryCustomizer private final TomcatServerProperties tomcatProperties; + private final WebProperties webProperties; + public TomcatWebServerFactoryCustomizer(Environment environment, ServerProperties serverProperties, - TomcatServerProperties tomcatProperties) { + TomcatServerProperties tomcatProperties, WebProperties webProperties) { this.environment = environment; this.serverProperties = serverProperties; this.tomcatProperties = tomcatProperties; + this.webProperties = webProperties; } @Override @@ -161,7 +165,7 @@ public class TomcatWebServerFactoryCustomizer .as((enable) -> !enable) .to(factory::setDisableMBeanRegistry); customizeStaticResources(factory); - customizeErrorReportValve(this.serverProperties.getError(), factory); + customizeErrorReportValve(this.webProperties.getError(), factory); factory.setUseApr(getUseApr(this.tomcatProperties.getUseApr())); } diff --git a/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizerTests.java b/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizerTests.java index ccef1fdb82c..81ff6af9b51 100644 --- a/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizerTests.java +++ b/module/spring-boot-tomcat/src/test/java/org/springframework/boot/tomcat/autoconfigure/TomcatWebServerFactoryCustomizerTests.java @@ -34,6 +34,7 @@ import org.jspecify.annotations.Nullable; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; @@ -74,13 +75,15 @@ class TomcatWebServerFactoryCustomizerTests { private final TomcatServerProperties tomcatProperties = new TomcatServerProperties(); + private final WebProperties webProperties = new WebProperties(); + private TomcatWebServerFactoryCustomizer customizer; @BeforeEach void setup() { ConfigurationPropertySources.attach(this.environment); this.customizer = new TomcatWebServerFactoryCustomizer(this.environment, this.serverProperties, - this.tomcatProperties); + this.tomcatProperties, this.webProperties); } @Test diff --git a/module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/autoconfigure/ServerProperties.java b/module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/autoconfigure/ServerProperties.java index 5669c08ad49..32629886c8a 100644 --- a/module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/autoconfigure/ServerProperties.java +++ b/module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/autoconfigure/ServerProperties.java @@ -26,7 +26,6 @@ import java.util.Map; import org.jspecify.annotations.Nullable; -import org.springframework.boot.autoconfigure.web.ErrorProperties; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.NestedConfigurationProperty; import org.springframework.boot.convert.DurationUnit; @@ -83,9 +82,6 @@ public class ServerProperties { */ private @Nullable InetAddress address; - @NestedConfigurationProperty - private final ErrorProperties error = new ErrorProperties(); - /** * Strategy for handling X-Forwarded-* headers. */ @@ -168,10 +164,6 @@ public class ServerProperties { this.shutdown = shutdown; } - public ErrorProperties getError() { - return this.error; - } - public @Nullable Ssl getSsl() { return this.ssl; } diff --git a/module/spring-boot-web-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/module/spring-boot-web-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 858e8eff87e..dcb8c46cfd1 100644 --- a/module/spring-boot-web-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/module/spring-boot-web-server/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -12,37 +12,72 @@ { "name": "server.error.include-binding-errors", "description": "When to include \"errors\" attribute.", - "defaultValue": "never" + "defaultValue": "never", + "deprecation": { + "level": "error", + "replacement": "spring.web.error.include-binding-errors", + "since": "4.0.0" + } }, { "name": "server.error.include-exception", "description": "Include the \"exception\" attribute.", - "defaultValue": false + "defaultValue": false, + "deprecation": { + "level": "error", + "replacement": "spring.web.error.include-exception", + "since": "4.0.0" + } }, { "name": "server.error.include-message", "description": "When to include the \"message\" attribute.", - "defaultValue": "never" + "defaultValue": "never", + "deprecation": { + "level": "error", + "replacement": "spring.web.error.include-message", + "since": "4.0.0" + } }, { "name": "server.error.include-path", "description": "When to include the \"path\" attribute.", - "defaultValue": "always" + "defaultValue": "always", + "deprecation": { + "level": "error", + "replacement": "spring.web.error.include-path", + "since": "4.0.0" + } }, { "name": "server.error.include-stacktrace", "description": "When to include the \"trace\" attribute.", - "defaultValue": "never" + "defaultValue": "never", + "deprecation": { + "level": "error", + "replacement": "spring.web.error.include-stacktrace", + "since": "4.0.0" + } }, { "name": "server.error.path", "description": "Path of the error controller", - "defaultValue": "/error" + "defaultValue": "/error", + "deprecation": { + "level": "error", + "replacement": "spring.web.error.path", + "since": "4.0.0" + } }, { "name": "server.error.whitelabel.enabled", "description": "Whether to enable the default error page displayed in browsers in case of a server error.", - "defaultValue": true + "defaultValue": true , + "deprecation": { + "level": "error", + "replacement": "spring.web.error.whitelabel.enabled", + "since": "4.0.0" + } }, { "name": "server.max-http-header-size", diff --git a/module/spring-boot-web-server/src/main/resources/META-INF/spring-devtools.properties b/module/spring-boot-web-server/src/main/resources/META-INF/spring-devtools.properties index bd1efd90b50..b86bcf5d571 100644 --- a/module/spring-boot-web-server/src/main/resources/META-INF/spring-devtools.properties +++ b/module/spring-boot-web-server/src/main/resources/META-INF/spring-devtools.properties @@ -1,5 +1,2 @@ -defaults.server.error.include-binding-errors=always -defaults.server.error.include-message=always -defaults.server.error.include-stacktrace=always defaults.server.servlet.jsp.init-parameters.development=true defaults.server.servlet.session.persistent=true diff --git a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/error/ErrorWebFluxAutoConfiguration.java b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/error/ErrorWebFluxAutoConfiguration.java index 9fdfb2d8211..95316962c2a 100644 --- a/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/error/ErrorWebFluxAutoConfiguration.java +++ b/module/spring-boot-webflux/src/main/java/org/springframework/boot/webflux/autoconfigure/error/ErrorWebFluxAutoConfiguration.java @@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfiguration; import org.springframework.boot.webflux.error.DefaultErrorAttributes; import org.springframework.boot.webflux.error.ErrorAttributes; @@ -49,15 +48,9 @@ import org.springframework.web.reactive.result.view.ViewResolver; @AutoConfiguration(before = WebFluxAutoConfiguration.class) @ConditionalOnWebApplication(type = Type.REACTIVE) @ConditionalOnClass(WebFluxConfigurer.class) -@EnableConfigurationProperties({ ServerProperties.class, WebProperties.class }) +@EnableConfigurationProperties(WebProperties.class) public final class ErrorWebFluxAutoConfiguration { - private final ServerProperties serverProperties; - - ErrorWebFluxAutoConfiguration(ServerProperties serverProperties) { - this.serverProperties = serverProperties; - } - @Bean @ConditionalOnMissingBean(search = SearchStrategy.CURRENT) @Order(-1) @@ -65,7 +58,7 @@ public final class ErrorWebFluxAutoConfiguration { ObjectProvider viewResolvers, ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) { DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, - webProperties.getResources(), this.serverProperties.getError(), applicationContext); + webProperties.getResources(), webProperties.getError(), applicationContext); exceptionHandler.setViewResolvers(viewResolvers.orderedStream().toList()); exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters()); exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders()); diff --git a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java index d19a3cc4c4b..ca43ecc752e 100644 --- a/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java +++ b/module/spring-boot-webflux/src/test/java/org/springframework/boot/webflux/autoconfigure/error/DefaultErrorWebExceptionHandlerIntegrationTests.java @@ -41,7 +41,6 @@ import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.error.ErrorAttributeOptions.Include; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webflux.autoconfigure.HttpHandlerAutoConfiguration; import org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfiguration; import org.springframework.boot.webflux.error.DefaultErrorAttributes; @@ -181,7 +180,8 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void bindingResultErrorIncludeMessageAndErrors() { this.contextRunner - .withPropertyValues("server.error.include-message=on-param", "server.error.include-binding-errors=on-param") + .withPropertyValues("spring.web.error.include-message=on-param", + "spring.web.error.include-binding-errors=on-param") .run((context) -> { WebTestClient client = getWebClient(context); client.post() @@ -212,7 +212,8 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void includeStackTraceOnParam() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-stacktrace=on-param") + .withPropertyValues("spring.web.error.include-exception=true", + "spring.web.error.include-stacktrace=on-param") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -237,7 +238,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void alwaysIncludeStackTrace() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-stacktrace=always") + .withPropertyValues("spring.web.error.include-exception=true", "spring.web.error.include-stacktrace=always") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -262,7 +263,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void neverIncludeStackTrace() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-stacktrace=never") + .withPropertyValues("spring.web.error.include-exception=true", "spring.web.error.include-stacktrace=never") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -287,7 +288,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void includeMessageOnParam() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-message=on-param") + .withPropertyValues("spring.web.error.include-exception=true", "spring.web.error.include-message=on-param") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -312,7 +313,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void alwaysIncludeMessage() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-message=always") + .withPropertyValues("spring.web.error.include-exception=true", "spring.web.error.include-message=always") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -337,7 +338,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void neverIncludeMessage() { this.contextRunner - .withPropertyValues("server.error.include-exception=true", "server.error.include-message=never") + .withPropertyValues("spring.web.error.include-exception=true", "spring.web.error.include-message=never") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -361,7 +362,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void statusException() { - this.contextRunner.withPropertyValues("server.error.include-exception=true").run((context) -> { + this.contextRunner.withPropertyValues("spring.web.error.include-exception=true").run((context) -> { WebTestClient client = getWebClient(context); client.get() .uri("/badRequest") @@ -383,8 +384,8 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void defaultErrorView() { this.contextRunner - .withPropertyValues("spring.mustache.prefix=classpath:/unknown/", "server.error.include-stacktrace=always", - "server.error.include-message=always") + .withPropertyValues("spring.mustache.prefix=classpath:/unknown/", + "spring.web.error.include-stacktrace=always", "spring.web.error.include-message=always") .run((context) -> { WebTestClient client = getWebClient(context); String body = client.get() @@ -408,7 +409,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void escapeHtmlInDefaultErrorView() { this.contextRunner - .withPropertyValues("spring.mustache.prefix=classpath:/unknown/", "server.error.include-message=always") + .withPropertyValues("spring.mustache.prefix=classpath:/unknown/", "spring.web.error.include-message=always") .run((context) -> { WebTestClient client = getWebClient(context); String body = client.get() @@ -464,7 +465,8 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Test void whitelabelDisabled() { this.contextRunner - .withPropertyValues("server.error.whitelabel.enabled=false", "spring.mustache.prefix=classpath:/unknown/") + .withPropertyValues("spring.web.error.whitelabel.enabled=false", + "spring.mustache.prefix=classpath:/unknown/") .run((context) -> { WebTestClient client = getWebClient(context); client.get() @@ -667,12 +669,11 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { @Bean @Order(-1) - ErrorWebExceptionHandler errorWebExceptionHandler(ServerProperties serverProperties, - ErrorAttributes errorAttributes, WebProperties webProperties, + ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes, WebProperties webProperties, ObjectProvider viewResolvers, ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) { DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes, - webProperties.getResources(), serverProperties.getError(), applicationContext) { + webProperties.getResources(), webProperties.getError(), applicationContext) { @Override protected ErrorAttributeOptions getErrorAttributeOptions(ServerRequest request, MediaType mediaType) { diff --git a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java index 0704d376cd6..80f50d32b9c 100644 --- a/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc-test/src/main/java/org/springframework/boot/webmvc/test/autoconfigure/MockMvcAutoConfiguration.java @@ -21,7 +21,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath; import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.WebMvcProperties; @@ -42,7 +41,7 @@ import org.springframework.web.servlet.DispatcherServlet; */ @AutoConfiguration(after = WebMvcAutoConfiguration.class) @ConditionalOnWebApplication(type = Type.SERVLET) -@EnableConfigurationProperties({ ServerProperties.class, WebMvcProperties.class }) +@EnableConfigurationProperties(WebMvcProperties.class) @Import({ MockMvcConfiguration.class, MockMvcTesterConfiguration.class }) public final class MockMvcAutoConfiguration { diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/ManagementErrorEndpoint.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/ManagementErrorEndpoint.java index cff73de1ffc..e12ada13a10 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/ManagementErrorEndpoint.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/ManagementErrorEndpoint.java @@ -55,7 +55,7 @@ public class ManagementErrorEndpoint { this.errorProperties = errorProperties; } - @RequestMapping("${server.error.path:${error.path:/error}}") + @RequestMapping("${spring.web.error.path:${error.path:/error}}") @ResponseBody public Map invoke(ServletWebRequest request) { return this.errorAttributes.getErrorAttributes(request, getErrorAttributeOptions(request)); diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfiguration.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfiguration.java index f0fbadf1749..f9b1001cac3 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfiguration.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfiguration.java @@ -24,10 +24,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.servlet.filter.OrderedRequestContextFilter; import org.springframework.boot.web.error.ErrorPage; import org.springframework.boot.web.server.WebServerFactoryCustomizer; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.web.server.servlet.ConfigurableServletWebServerFactory; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletRegistrationBean; @@ -61,14 +61,14 @@ class WebMvcEndpointChildContextConfiguration { */ @Bean @ConditionalOnBean(ErrorAttributes.class) - ManagementErrorEndpoint errorEndpoint(ErrorAttributes errorAttributes, ServerProperties serverProperties) { - return new ManagementErrorEndpoint(errorAttributes, serverProperties.getError()); + ManagementErrorEndpoint errorEndpoint(ErrorAttributes errorAttributes, WebProperties webProperties) { + return new ManagementErrorEndpoint(errorAttributes, webProperties.getError()); } @Bean @ConditionalOnBean(ErrorAttributes.class) - ManagementErrorPageCustomizer managementErrorPageCustomizer(ServerProperties serverProperties) { - return new ManagementErrorPageCustomizer(serverProperties); + ManagementErrorPageCustomizer managementErrorPageCustomizer(WebProperties webProperties) { + return new ManagementErrorPageCustomizer(webProperties); } @Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME) @@ -115,9 +115,9 @@ class WebMvcEndpointChildContextConfiguration { static class ManagementErrorPageCustomizer implements WebServerFactoryCustomizer, Ordered { - private final ServerProperties properties; + private final WebProperties properties; - ManagementErrorPageCustomizer(ServerProperties properties) { + ManagementErrorPageCustomizer(WebProperties properties) { this.properties = properties; } diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorController.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorController.java index e32e92aa794..eb7be92a00f 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorController.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorController.java @@ -57,7 +57,7 @@ import org.springframework.web.servlet.ModelAndView; * @see ErrorProperties */ @Controller -@RequestMapping("${server.error.path:${error.path:/error}}") +@RequestMapping("${spring.web.error.path:${error.path:/error}}") public class BasicErrorController extends AbstractErrorController { private final ErrorProperties errorProperties; diff --git a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/ErrorMvcAutoConfiguration.java b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/ErrorMvcAutoConfiguration.java index 320137badf2..d7a81a02356 100644 --- a/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/ErrorMvcAutoConfiguration.java +++ b/module/spring-boot-webmvc/src/main/java/org/springframework/boot/webmvc/autoconfigure/error/ErrorMvcAutoConfiguration.java @@ -51,7 +51,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.web.error.ErrorPage; import org.springframework.boot.web.error.ErrorPageRegistrar; import org.springframework.boot.web.error.ErrorPageRegistry; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletPath; import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.WebMvcProperties; @@ -87,14 +86,14 @@ import org.springframework.web.util.HtmlUtils; // Load before the main WebMvcAutoConfiguration so that the error View is available @AutoConfiguration(before = WebMvcAutoConfiguration.class) @ConditionalOnWebApplication(type = Type.SERVLET) -@ConditionalOnClass({ Servlet.class, DispatcherServlet.class, ServerProperties.class }) -@EnableConfigurationProperties({ ServerProperties.class, WebMvcProperties.class }) +@ConditionalOnClass({ Servlet.class, DispatcherServlet.class }) +@EnableConfigurationProperties({ WebProperties.class, WebMvcProperties.class }) public final class ErrorMvcAutoConfiguration { - private final ServerProperties serverProperties; + private final WebProperties webProperties; - ErrorMvcAutoConfiguration(ServerProperties serverProperties) { - this.serverProperties = serverProperties; + ErrorMvcAutoConfiguration(WebProperties webProperties) { + this.webProperties = webProperties; } @Bean @@ -107,13 +106,13 @@ public final class ErrorMvcAutoConfiguration { @ConditionalOnMissingBean(value = ErrorController.class, search = SearchStrategy.CURRENT) BasicErrorController basicErrorController(ErrorAttributes errorAttributes, ObjectProvider errorViewResolvers) { - return new BasicErrorController(errorAttributes, this.serverProperties.getError(), + return new BasicErrorController(errorAttributes, this.webProperties.getError(), errorViewResolvers.orderedStream().toList()); } @Bean ErrorPageCustomizer errorPageCustomizer(DispatcherServletPath dispatcherServletPath) { - return new ErrorPageCustomizer(this.serverProperties, dispatcherServletPath); + return new ErrorPageCustomizer(this.webProperties, dispatcherServletPath); } @Bean @@ -122,7 +121,6 @@ public final class ErrorMvcAutoConfiguration { } @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties({ WebProperties.class, WebMvcProperties.class }) static class DefaultErrorViewResolverConfiguration { private final ApplicationContext applicationContext; @@ -144,7 +142,7 @@ public final class ErrorMvcAutoConfiguration { } @Configuration(proxyBeanMethods = false) - @ConditionalOnBooleanProperty(name = "server.error.whitelabel.enabled", matchIfMissing = true) + @ConditionalOnBooleanProperty(name = "spring.web.error.whitelabel.enabled", matchIfMissing = true) @Conditional(ErrorTemplateMissingCondition.class) protected static class WhitelabelErrorViewConfiguration { @@ -263,11 +261,11 @@ public final class ErrorMvcAutoConfiguration { */ static class ErrorPageCustomizer implements ErrorPageRegistrar, Ordered { - private final ServerProperties properties; + private final WebProperties properties; private final DispatcherServletPath dispatcherServletPath; - protected ErrorPageCustomizer(ServerProperties properties, DispatcherServletPath dispatcherServletPath) { + protected ErrorPageCustomizer(WebProperties properties, DispatcherServletPath dispatcherServletPath) { this.properties = properties; this.dispatcherServletPath = dispatcherServletPath; } diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfigurationIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfigurationIntegrationTests.java index 36f16d9e370..9b4deb8ea19 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfigurationIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/actuate/web/WebMvcEndpointChildContextConfigurationIntegrationTests.java @@ -79,8 +79,8 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { .withUserConfiguration(SucceedingEndpoint.class, FailingEndpoint.class, FailingControllerEndpoint.class) .withInitializer(new ServerPortInfoApplicationContextInitializer()) .withPropertyValues("server.port=0", "management.server.port=0", "management.endpoints.web.exposure.include=*", - "server.error.include-exception=true", "server.error.include-message=always", - "server.error.include-binding-errors=always"); + "spring.web.error.include-exception=true", "spring.web.error.include-message=always", + "spring.web.error.include-binding-errors=always"); @TempDir @SuppressWarnings("NullAway.Init") @@ -102,7 +102,8 @@ class WebMvcEndpointChildContextConfigurationIntegrationTests { @Test void errorPageAndErrorControllerIncludeDetails() { - this.runner.withPropertyValues("server.error.include-stacktrace=always", "server.error.include-message=always") + this.runner + .withPropertyValues("spring.web.error.include-stacktrace=always", "spring.web.error.include-message=always") .run(withRestClient((client) -> { Map body = client.get() .uri("actuator/fail") diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerDirectMockMvcTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerDirectMockMvcTests.java index a938153ec09..f55c72b9389 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerDirectMockMvcTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerDirectMockMvcTests.java @@ -95,7 +95,7 @@ class BasicErrorControllerDirectMockMvcTests { @Test void errorPageNotAvailableWithWhitelabelDisabled() { setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class) - .run("--server.port=0", "--server.error.whitelabel.enabled=false")); + .run("--server.port=0", "--spring.web.error.whitelabel.enabled=false")); assertThat(this.mvc.get().uri("/error").accept(MediaType.TEXT_HTML)).hasFailed() .failure() .isInstanceOf(ServletException.class); diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java index b825a6d1804..404162d6e21 100755 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerIntegrationTests.java @@ -41,12 +41,12 @@ import org.springframework.beans.factory.ObjectProvider; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.resttestclient.TestRestTemplate; import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.error.ErrorAttributeOptions.Include; -import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; import org.springframework.boot.webmvc.error.ErrorAttributes; @@ -104,43 +104,43 @@ class BasicErrorControllerIntegrationTests { @Test void testErrorForMachineClientWithParamsTrue() { - load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-param", - "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-stacktrace=on-param", + "--spring.web.error.include-message=on-param"); exceptionWithStackTraceAndMessage("?trace=true&message=true"); } @Test void testErrorForMachineClientWithParamsFalse() { - load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-param", - "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-stacktrace=on-param", + "--spring.web.error.include-message=on-param"); exceptionWithoutStackTraceAndMessage("?trace=false&message=false"); } @Test void testErrorForMachineClientWithParamsAbsent() { - load("--server.error.include-exception=true", "--server.error.include-stacktrace=on-param", - "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-stacktrace=on-param", + "--spring.web.error.include-message=on-param"); exceptionWithoutStackTraceAndMessage(""); } @Test void testErrorForMachineClientNeverParams() { - load("--server.error.include-exception=true", "--server.error.include-stacktrace=never", - "--server.error.include-message=never"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-stacktrace=never", + "--spring.web.error.include-message=never"); exceptionWithoutStackTraceAndMessage("?trace=true&message=true"); } @Test void testErrorForMachineClientAlwaysParams() { - load("--server.error.include-exception=true", "--server.error.include-stacktrace=always", - "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-stacktrace=always", + "--spring.web.error.include-message=always"); exceptionWithStackTraceAndMessage("?trace=false&message=false"); } @Test @SuppressWarnings("rawtypes") void testErrorForMachineClientAlwaysParamsWithoutMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=always"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/noMessage"), Map.class); assertErrorAttributes(entity.getBody(), "500", "Internal Server Error", IllegalStateException.class, "No message available", "/noMessage"); @@ -164,7 +164,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings("rawtypes") void testErrorForAnnotatedExceptionWithoutMessage() { - load("--server.error.include-exception=true"); + load("--spring.web.error.include-exception=true"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/annotated"), Map.class); assertErrorAttributes(entity.getBody(), "400", "Bad Request", TestConfiguration.Errors.ExpectedException.class, null, "/annotated"); @@ -173,7 +173,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings("rawtypes") void testErrorForAnnotatedExceptionWithMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=always"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/annotated"), Map.class); assertErrorAttributes(entity.getBody(), "400", "Bad Request", TestConfiguration.Errors.ExpectedException.class, "Expected!", "/annotated"); @@ -182,7 +182,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings("rawtypes") void testErrorForAnnotatedNoReasonExceptionWithoutMessage() { - load("--server.error.include-exception=true"); + load("--spring.web.error.include-exception=true"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/annotatedNoReason"), Map.class); assertErrorAttributes(entity.getBody(), "406", "Not Acceptable", TestConfiguration.Errors.NoReasonExpectedException.class, null, "/annotatedNoReason"); @@ -191,7 +191,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings("rawtypes") void testErrorForAnnotatedNoReasonExceptionWithMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=always"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/annotatedNoReason"), Map.class); assertErrorAttributes(entity.getBody(), "406", "Not Acceptable", TestConfiguration.Errors.NoReasonExpectedException.class, "Expected message", "/annotatedNoReason"); @@ -200,7 +200,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings("rawtypes") void testErrorForAnnotatedNoMessageExceptionWithMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=always"); ResponseEntity entity = new TestRestTemplate().getForEntity(createUrl("/annotatedNoMessage"), Map.class); assertErrorAttributes(entity.getBody(), "406", "Not Acceptable", TestConfiguration.Errors.NoReasonExpectedException.class, "No message available", @@ -209,61 +209,61 @@ class BasicErrorControllerIntegrationTests { @Test void testBindingExceptionForMachineClientWithErrorsParamTrue() { - load("--server.error.include-exception=true", "--server.error.include-binding-errors=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-binding-errors=on-param"); bindingExceptionWithErrors("?errors=true"); } @Test void testBindingExceptionForMachineClientWithErrorsParamFalse() { - load("--server.error.include-exception=true", "--server.error.include-binding-errors=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-binding-errors=on-param"); bindingExceptionWithoutErrors("?errors=false"); } @Test void testBindingExceptionForMachineClientWithErrorsParamAbsent() { - load("--server.error.include-exception=true", "--server.error.include-binding-errors=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-binding-errors=on-param"); bindingExceptionWithoutErrors(""); } @Test void testBindingExceptionForMachineClientAlwaysErrors() { - load("--server.error.include-exception=true", "--server.error.include-binding-errors=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-binding-errors=always"); bindingExceptionWithErrors("?errors=false"); } @Test void testBindingExceptionForMachineClientNeverErrors() { - load("--server.error.include-exception=true", "--server.error.include-binding-errors=never"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-binding-errors=never"); bindingExceptionWithoutErrors("?errors=true"); } @Test void testBindingExceptionForMachineClientWithMessageParamTrue() { - load("--server.error.include-exception=true", "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=on-param"); bindingExceptionWithMessage("?message=true"); } @Test void testBindingExceptionForMachineClientWithMessageParamFalse() { - load("--server.error.include-exception=true", "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=on-param"); bindingExceptionWithoutMessage("?message=false"); } @Test void testBindingExceptionForMachineClientWithMessageParamAbsent() { - load("--server.error.include-exception=true", "--server.error.include-message=on-param"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=on-param"); bindingExceptionWithoutMessage(""); } @Test void testBindingExceptionForMachineClientAlwaysMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=always"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=always"); bindingExceptionWithMessage("?message=false"); } @Test void testBindingExceptionForMachineClientNeverMessage() { - load("--server.error.include-exception=true", "--server.error.include-message=never"); + load("--spring.web.error.include-exception=true", "--spring.web.error.include-message=never"); bindingExceptionWithoutMessage("?message=true"); } @@ -302,7 +302,7 @@ class BasicErrorControllerIntegrationTests { @Test @SuppressWarnings({ "rawtypes", "unchecked" }) void testRequestBodyValidationForMachineClient() { - load("--server.error.include-exception=true"); + load("--spring.web.error.include-exception=true"); RequestEntity request = RequestEntity.post(URI.create(createUrl("/bodyValidation"))) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) @@ -509,9 +509,9 @@ class BasicErrorControllerIntegrationTests { static class CustomErrorControllerWithoutStatusConfiguration extends TestConfiguration { @Bean - BasicErrorController basicErrorController(ServerProperties serverProperties, ErrorAttributes errorAttributes, + BasicErrorController basicErrorController(WebProperties webProperties, ErrorAttributes errorAttributes, ObjectProvider errorViewResolvers) { - return new BasicErrorController(errorAttributes, serverProperties.getError(), + return new BasicErrorController(errorAttributes, webProperties.getError(), errorViewResolvers.orderedStream().toList()) { @Override diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerMockMvcTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerMockMvcTests.java index b82c705dec9..e51a80beb0a 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerMockMvcTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/BasicErrorControllerMockMvcTests.java @@ -71,7 +71,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Dave Syer * @author Scott Frederick */ -@SpringBootTest(properties = { "server.error.include-message=always", "debug=true" }) +@SpringBootTest(properties = { "spring.web.error.include-message=always", "debug=true" }) @DirtiesContext class BasicErrorControllerMockMvcTests { diff --git a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/DefaultErrorViewIntegrationTests.java b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/DefaultErrorViewIntegrationTests.java index 119bcc5f8be..4479c917ce9 100644 --- a/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/DefaultErrorViewIntegrationTests.java +++ b/module/spring-boot-webmvc/src/test/java/org/springframework/boot/webmvc/autoconfigure/error/DefaultErrorViewIntegrationTests.java @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Dave Syer * @author Scott Frederick */ -@SpringBootTest(properties = { "server.error.include-message=always" }) +@SpringBootTest(properties = { "spring.web.error.include-message=always" }) @DirtiesContext class DefaultErrorViewIntegrationTests { diff --git a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java index e2e9becc893..3ea64559524 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Scott Frederick */ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { "server.error.include-message=always" }) + properties = { "spring.web.error.include-message=always" }) class SampleActuatorCustomSecurityApplicationTests extends AbstractSampleActuatorCustomSecurityTests { @LocalServerPort diff --git a/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java index 70a8ec21167..9f640e6ea04 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-extension/src/test/java/smoketest/actuator/extension/SampleActuatorExtensionApplicationTests.java @@ -33,7 +33,7 @@ import org.springframework.http.ResponseEntity; import static org.assertj.core.api.Assertions.assertThat; -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "server.error.include-message=always" }) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "spring.web.error.include-message=always" }) @AutoConfigureTestRestTemplate class SampleActuatorExtensionApplicationTests { diff --git a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java index 46918130227..705474d3c5a 100644 --- a/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java +++ b/smoke-test/spring-boot-smoke-test-actuator-ui/src/test/java/smoketest/actuator/ui/SampleActuatorUiApplicationTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Dave Syer */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "server.error.include-message=always" }) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "spring.web.error.include-message=always" }) @AutoConfigureTestRestTemplate class SampleActuatorUiApplicationTests { diff --git a/smoke-test/spring-boot-smoke-test-actuator/src/test/resources/application-endpoints.properties b/smoke-test/spring-boot-smoke-test-actuator/src/test/resources/application-endpoints.properties index 5f8c1d2bedd..4a54886b6a8 100644 --- a/smoke-test/spring-boot-smoke-test-actuator/src/test/resources/application-endpoints.properties +++ b/smoke-test/spring-boot-smoke-test-actuator/src/test/resources/application-endpoints.properties @@ -1,3 +1,3 @@ -server.error.path:/oops +spring.web.error.path:/oops management.endpoint.health.show-details:always management.endpoints.web.base-path:/admin diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathErrorPageTests.java index c6e27f634a1..2c8e15fd656 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathErrorPageTests.java @@ -28,7 +28,7 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, ErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password", "server.servlet.context-path=/example" }) class CustomContextPathErrorPageTests extends AbstractErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathUnauthenticatedErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathUnauthenticatedErrorPageTests.java index 2577d5e0cc1..859f808afc3 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathUnauthenticatedErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomContextPathUnauthenticatedErrorPageTests.java @@ -26,7 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, UnauthenticatedErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password", "server.servlet.context-path=/example" }) class CustomContextPathUnauthenticatedErrorPageTests extends AbstractUnauthenticatedErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java index 2cf22d987ef..29fd2d2cb83 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathErrorPageTests.java @@ -33,7 +33,7 @@ import static org.springframework.security.config.Customizer.withDefaults; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, CustomServletPathErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password", "spring.mvc.servlet.path=/custom/servlet/path" }) class CustomServletPathErrorPageTests extends AbstractErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathUnauthenticatedErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathUnauthenticatedErrorPageTests.java index 01e9a2955e6..9038ac1966e 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathUnauthenticatedErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/CustomServletPathUnauthenticatedErrorPageTests.java @@ -32,7 +32,7 @@ import static org.springframework.security.config.Customizer.withDefaults; classes = { AbstractErrorPageTests.TestConfiguration.class, CustomServletPathUnauthenticatedErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password", "spring.mvc.servlet.path=/custom/servlet/path" }) class CustomServletPathUnauthenticatedErrorPageTests extends AbstractUnauthenticatedErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java index fc0b9a52242..b06e3df447d 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/ErrorPageTests.java @@ -32,7 +32,7 @@ import static org.springframework.security.config.Customizer.withDefaults; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, ErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password" }) class ErrorPageTests extends AbstractErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java index 63541354745..58cce893451 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/NoSessionErrorPageTests.java @@ -33,7 +33,7 @@ import static org.springframework.security.config.Customizer.withDefaults; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, NoSessionErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password" }) class NoSessionErrorPageTests extends AbstractErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/UnauthenticatedErrorPageTests.java b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/UnauthenticatedErrorPageTests.java index 394b7ec08c3..c178e6dc6cf 100644 --- a/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/UnauthenticatedErrorPageTests.java +++ b/smoke-test/spring-boot-smoke-test-web-secure/src/test/java/smoketest/web/secure/UnauthenticatedErrorPageTests.java @@ -32,7 +32,7 @@ import static org.springframework.security.config.Customizer.withDefaults; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes = { AbstractErrorPageTests.TestConfiguration.class, UnauthenticatedErrorPageTests.SecurityConfiguration.class, SampleWebSecureApplication.class }, - properties = { "server.error.include-message=always", "spring.security.user.name=username", + properties = { "spring.web.error.include-message=always", "spring.security.user.name=username", "spring.security.user.password=password" }) class UnauthenticatedErrorPageTests extends AbstractUnauthenticatedErrorPageTests { diff --git a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java index 445aaf69e07..9461a0f8517 100644 --- a/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java +++ b/smoke-test/spring-boot-smoke-test-webflux/src/test/java/smoketest/webflux/SampleWebFluxApplicationIntegrationTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Brian Clozel */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "server.error.include-message=always") +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "spring.web.error.include-message=always") @AutoConfigureWebTestClient class SampleWebFluxApplicationIntegrationTests {