diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 85270dff1e..65bd68f914 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -68,11 +68,6 @@ public class ServerProperties { */ private InetAddress address; - /** - * Display name of the application. - */ - private String displayName = "application"; - @NestedConfigurationProperty private final ErrorProperties error = new ErrorProperties(); @@ -131,14 +126,6 @@ public class ServerProperties { this.address = address; } - public String getDisplayName() { - return this.displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - public Boolean isUseForwardHeaders() { return this.useForwardHeaders; } @@ -222,6 +209,11 @@ public class ServerProperties { */ private String contextPath; + /** + * Display name of the application. + */ + private String applicationDisplayName = "application"; + /** * Path of the main dispatcher servlet. */ @@ -248,6 +240,14 @@ public class ServerProperties { return contextPath; } + public String getApplicationDisplayName() { + return this.applicationDisplayName; + } + + public void setApplicationDisplayName(String displayName) { + this.applicationDisplayName = displayName; + } + public String getPath() { return this.path; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java index dc5f50b3ec..4052e8df2a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java @@ -74,7 +74,7 @@ public class DefaultServletWebServerFactoryCustomizer map.from(this.serverProperties::getAddress).to(factory::setAddress); map.from(this.serverProperties.getServlet()::getContextPath) .to(factory::setContextPath); - map.from(this.serverProperties::getDisplayName).to(factory::setDisplayName); + map.from(this.serverProperties.getServlet()::getApplicationDisplayName).to(factory::setDisplayName); map.from(this.serverProperties.getServlet()::getSession).to(factory::setSession); map.from(this.serverProperties::getSsl).to(factory::setSsl); map.from(this.serverProperties::getServlet).as(ServerProperties.Servlet::getJsp) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 34cd2b492a..b1807d5072 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -977,6 +977,16 @@ "level": "error" } }, + { + "name" : "server.display-name", + "type" : "java.lang.String", + "description" : "Display name of the application.", + "defaultValue" : "application", + "deprecation" : { + "replacement" : "server.servlet.application-display-name", + "level" : "error" + } + }, { "name": "server.jsp-servlet.class-name", "type": "java.lang.String", diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java index dd8b314526..e54f1b10d5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java @@ -216,7 +216,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { public void testCustomizeDisplayName() { ConfigurableServletWebServerFactory factory = mock( ConfigurableServletWebServerFactory.class); - this.properties.setDisplayName("TestName"); + this.properties.getServlet().setApplicationDisplayName("TestName"); this.customizer.customize(factory); verify(factory).setDisplayName("TestName"); } @@ -281,7 +281,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { @Test public void customizeTomcatDisplayName() { Map map = new HashMap<>(); - map.put("server.display-name", "MyBootApp"); + map.put("server.servlet.application-display-name", "MyBootApp"); bindProperties(map); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); this.customizer.customize(factory); diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 84e471527a..893faa39b2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -165,7 +165,6 @@ content into your application. Rather, pick only the properties that you need. server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript # Comma-separated list of MIME types that should be compressed. server.compression.min-response-size=2048 # Minimum response size that is required for compression to be performed. server.connection-timeout= # Time that connectors wait for another HTTP request before closing the connection. When not set, the connector's container-specific default is used. Use a value of -1 to indicate no (that is, an infinite) timeout. - server.display-name=application # Display name of the application. server.error.include-exception=false # Include the "exception" attribute. server.error.include-stacktrace=never # When to include a "stacktrace" attribute. server.error.path=/error # Path of the error controller. @@ -192,6 +191,7 @@ content into your application. Rather, pick only the properties that you need. server.use-forward-headers= # Whether X-Forwarded-* headers should be applied to the HttpRequest. server.servlet.context-parameters.*= # Servlet context init parameters server.servlet.context-path= # Context path of the application. + server.servlet.application-display-name=application # Display name of the application. server.servlet.jsp.class-name=org.apache.jasper.servlet.JspServlet # The class name of the JSP servlet. server.servlet.jsp.init-parameters.*= # Init parameters used to configure the JSP servlet. server.servlet.jsp.registered=true # Whether the JSP servlet is registered.