diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProvider.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProvider.java index 6880dd9b0e..99c13a4f59 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProvider.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProvider.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.stream.Collectors; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.EndpointInfo; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.util.Assert; @@ -36,12 +35,12 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider { private final Collection> endpoints; - private final String contextPath; + private final String basePath; public DefaultEndpointPathProvider(EndpointProvider provider, - ManagementServerProperties managementServerProperties) { + WebEndpointProperties webEndpointProperties) { this.endpoints = provider.getEndpoints(); - this.contextPath = managementServerProperties.getContextPath(); + this.basePath = webEndpointProperties.getBasePath(); } @Override @@ -57,7 +56,7 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider { } private String getPath(EndpointInfo endpointInfo) { - return this.contextPath + "/" + endpointInfo.getId(); + return this.basePath + "/" + endpointInfo.getId(); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 0000000000..b33b9df796 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + /** + * The base-path for the web endpoints. Relative to `server.context-path` or + * `management.server.context-path`, if `management.server.port` is different. + */ + private String basePath = "/application"; + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + +} + + diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java index a12126a245..db3e85073e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.jersey.JerseyEndpointResourceFactory; @@ -55,10 +55,10 @@ class JerseyWebEndpointManagementContextConfiguration { @Bean public ResourceConfigCustomizer webEndpointRegistrar( EndpointProvider provider, - ManagementServerProperties managementServerProperties) { + WebEndpointProperties webEndpointProperties) { return (resourceConfig) -> resourceConfig.registerResources( new HashSet<>(new JerseyEndpointResourceFactory().createEndpointResources( - new EndpointMapping(managementServerProperties.getContextPath()), + new EndpointMapping(webEndpointProperties.getBasePath()), provider.getEndpoints()))); } @@ -66,8 +66,8 @@ class JerseyWebEndpointManagementContextConfiguration { @ConditionalOnMissingBean public EndpointPathProvider endpointPathProvider( EndpointProvider provider, - ManagementServerProperties managementServerProperties) { - return new DefaultEndpointPathProvider(provider, managementServerProperties); + WebEndpointProperties webEndpointProperties) { + return new DefaultEndpointPathProvider(provider, webEndpointProperties); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java index 4d23de49b5..5520e78558 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/reactive/WebFluxEndpointManagementContextConfiguration.java @@ -19,8 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping; @@ -45,9 +45,9 @@ public class WebFluxEndpointManagementContextConfiguration { @ConditionalOnMissingBean public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping( EndpointProvider provider, - ManagementServerProperties managementServerProperties) { + WebEndpointProperties webEndpointProperties) { return new WebFluxEndpointHandlerMapping( - new EndpointMapping(managementServerProperties.getContextPath()), + new EndpointMapping(webEndpointProperties.getBasePath()), provider.getEndpoints()); } @@ -55,8 +55,8 @@ public class WebFluxEndpointManagementContextConfiguration { @ConditionalOnMissingBean public EndpointPathProvider endpointPathProvider( EndpointProvider provider, - ManagementServerProperties managementServerProperties) { - return new DefaultEndpointPathProvider(provider, managementServerProperties); + WebEndpointProperties webEndpointProperties) { + return new DefaultEndpointPathProvider(provider, webEndpointProperties); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java index 8338903fe0..152cd624a8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java @@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; import org.springframework.boot.actuate.autoconfigure.endpoint.web.EndpointPathProvider; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; @@ -48,7 +49,7 @@ import org.springframework.web.servlet.DispatcherServlet; @ConditionalOnClass(DispatcherServlet.class) @ConditionalOnBean(DispatcherServlet.class) @EnableConfigurationProperties({ CorsEndpointProperties.class, - ManagementServerProperties.class }) + WebEndpointProperties.class, ManagementServerProperties.class }) public class WebMvcEndpointManagementContextConfiguration { @Bean @@ -56,9 +57,9 @@ public class WebMvcEndpointManagementContextConfiguration { public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping( EndpointProvider provider, CorsEndpointProperties corsProperties, - ManagementServerProperties managementServerProperties) { + WebEndpointProperties webEndpointProperties) { WebMvcEndpointHandlerMapping handlerMapping = new WebMvcEndpointHandlerMapping( - new EndpointMapping(managementServerProperties.getContextPath()), + new EndpointMapping(webEndpointProperties.getBasePath()), provider.getEndpoints(), getCorsConfiguration(corsProperties)); return handlerMapping; } @@ -67,8 +68,8 @@ public class WebMvcEndpointManagementContextConfiguration { @ConditionalOnMissingBean public EndpointPathProvider endpointPathProvider( EndpointProvider provider, - ManagementServerProperties managementServerProperties) { - return new DefaultEndpointPathProvider(provider, managementServerProperties); + WebEndpointProperties webEndpointProperties) { + return new DefaultEndpointPathProvider(provider, webEndpointProperties); } private CorsConfiguration getCorsConfiguration(CorsEndpointProperties properties) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfiguration.java index 1ab0d97261..fc1cbc0227 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfiguration.java @@ -69,7 +69,7 @@ public class JolokiaManagementContextConfiguration { @Bean public ServletRegistrationBean jolokiaServlet() { - String path = this.managementServletContext.getContextPath() + String path = this.managementServletContext.getServletPath() + this.properties.getPath(); String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); ServletRegistrationBean registration = new ServletRegistrationBean<>( diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java index 8b608edd50..e28850aec6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java @@ -17,6 +17,7 @@ package org.springframework.boot.actuate.autoconfigure.web.server; import org.springframework.beans.factory.SmartInitializingSingleton; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; import org.springframework.boot.autoconfigure.AutoConfigureOrder; @@ -42,8 +43,8 @@ import org.springframework.web.context.ConfigurableWebApplicationContext; /** * {@link EnableAutoConfiguration Auto-configuration} for the management context. If the - * {@code management.port} is the same as the {@code server.port} the management context - * will be the same as the main application context. If the {@code management.port} is + * {@code management.server.port} is the same as the {@code server.port} the management context + * will be the same as the main application context. If the {@code management.server.port} is * different to the {@code server.port} the management context will be a separate context * that has the main application context as its parent. * @@ -52,7 +53,7 @@ import org.springframework.web.context.ConfigurableWebApplicationContext; */ @Configuration @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties({ WebEndpointProperties.class, ManagementServerProperties.class }) public class ManagementContextAutoConfiguration { @Configuration @@ -76,7 +77,7 @@ public class ManagementContextAutoConfiguration { } private void verifySslConfiguration() { - Boolean enabled = this.environment.getProperty("management.ssl.enabled", + Boolean enabled = this.environment.getProperty("management.server.ssl.enabled", Boolean.class, false); Assert.state(!enabled, "Management-specific SSL cannot be configured as the management " diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java index d0b2d76e3f..cbea996445 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java @@ -43,7 +43,7 @@ public enum ManagementPortType { static ManagementPortType get(Environment environment) { Integer serverPort = getPortProperty(environment, "server."); - Integer managementPort = getPortProperty(environment, "management."); + Integer managementPort = getPortProperty(environment, "management.server."); if (managementPort != null && managementPort < 0) { return DISABLED; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java index 28fda50e12..5e79eee3f6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java @@ -35,7 +35,7 @@ import org.springframework.util.StringUtils; * @since 2.0.0 * @see ServerProperties */ -@ConfigurationProperties(prefix = "management", ignoreUnknownFields = true) +@ConfigurationProperties(prefix = "management.server", ignoreUnknownFields = true) public class ManagementServerProperties implements SecurityPrerequisite { /** @@ -54,7 +54,7 @@ public class ManagementServerProperties implements SecurityPrerequisite { /** * Management endpoint context-path. */ - private String contextPath = "/application"; + private String contextPath = ""; /** * Add the "X-Application-Context" HTTP header in each response. diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementServletContext.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementServletContext.java index 94af0d3637..4266fd27ef 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementServletContext.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ManagementServletContext.java @@ -20,15 +20,16 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet; * Provides information about the management servlet context for MVC controllers to use. * * @author Phillip Webb + * @author Madhura Bhave * @since 2.0.0 */ @FunctionalInterface public interface ManagementServletContext { /** - * Return the context path of the management server. - * @return the context path + * Return the servlet path of the management server. + * @return the servlet path */ - String getContextPath(); + String getServletPath(); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java index 46c12d1969..3621744235 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java @@ -102,7 +102,7 @@ class ServletManagementChildContextConfiguration { ServerProperties serverProperties) { super.customize(webServerFactory, managementServerProperties, serverProperties); - webServerFactory.setContextPath(""); + webServerFactory.setContextPath(managementServerProperties.getContextPath()); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java index a410ba8a7e..55310dcf48 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java @@ -18,7 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet; import javax.servlet.Servlet; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -48,8 +48,8 @@ public class ServletManagementContextAutoConfiguration { @Bean public ManagementServletContext managementServletContext( - ManagementServerProperties properties) { - return () -> properties.getContextPath(); + WebEndpointProperties properties) { + return () -> properties.getBasePath(); } // Put Servlets and Filters in their own nested class so they don't force early diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProviderTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProviderTests.java index eb47289bbd..6a691a2f6a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProviderTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/DefaultEndpointPathProviderTests.java @@ -26,7 +26,6 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.endpoint.DefaultEnablement; import org.springframework.boot.actuate.endpoint.EndpointInfo; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; @@ -88,10 +87,10 @@ public class DefaultEndpointPathProviderTests { endpoints.add(new EndpointInfo<>("bar", DefaultEnablement.ENABLED, Collections.emptyList())); given(this.endpointProvider.getEndpoints()).willReturn(endpoints); - ManagementServerProperties managementServerProperties = new ManagementServerProperties(); - managementServerProperties.setContextPath(contextPath); + WebEndpointProperties webEndpointProperties = new WebEndpointProperties(); + webEndpointProperties.setBasePath(contextPath); return new DefaultEndpointPathProvider(this.endpointProvider, - managementServerProperties); + webEndpointProperties); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java new file mode 100644 index 0000000000..c30b35aca1 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointPropertiesTests.java @@ -0,0 +1,37 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link WebEndpointProperties}. + * + * @author Madhura Bhave + */ +public class WebEndpointPropertiesTests { + + @Test + public void defaultBasePathShouldBeApplication() throws Exception { + WebEndpointProperties properties = new WebEndpointProperties(); + assertThat(properties.getBasePath()).isEqualTo("/application"); + } + +} + diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java index 254006b84d..f5844f0d42 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java @@ -74,10 +74,10 @@ public class WebMvcEndpointIntegrationTests { } @Test - public void endpointsAreSecureByDefaultWithCustomContextPath() throws Exception { + public void endpointsAreSecureByDefaultWithCustomBasePath() throws Exception { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); - TestPropertyValues.of("management.context-path:/management") + TestPropertyValues.of("management.endpoints.web.base-path:/management") .applyTo(this.context); MockMvc mockMvc = createSecureMockMvc(); mockMvc.perform(get("/management/beans").accept(MediaType.APPLICATION_JSON)) @@ -85,13 +85,13 @@ public class WebMvcEndpointIntegrationTests { } @Test - public void endpointsAreSecureWithActuatorRoleWithCustomContextPath() + public void endpointsAreSecureWithActuatorRoleWithCustomBasePath() throws Exception { TestSecurityContextHolder.getContext().setAuthentication( new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); - TestPropertyValues.of("management.context-path:/management", + TestPropertyValues.of("management.endpoints.web.base-path:/management", "endpoints.default.web.enabled=true").applyTo(this.context); MockMvc mockMvc = createSecureMockMvc(); mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfigurationTests.java index 20e67ce51f..4e5cdf4092 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaManagementContextConfigurationTests.java @@ -76,7 +76,7 @@ public class JolokiaManagementContextConfigurationTests { public void customManagementPath() { this.contextRunner .withPropertyValues("management.jolokia.enabled=true", - "management.context-path=/admin") + "management.endpoints.web.base-path=/admin") .run(isDefinedOnPath("/admin/jolokia/*")); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java index a38a3f2ed1..480ef736f9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java @@ -46,7 +46,7 @@ public class ManagementServerPropertiesTests { public void defaultManagementServerProperties() { ManagementServerProperties properties = new ManagementServerProperties(); assertThat(properties.getPort()).isNull(); - assertThat(properties.getContextPath()).isEqualTo("/application"); + assertThat(properties.getContextPath()).isEqualTo(""); assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false); } 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 3f4551b2c2..07952d9038 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 @@ -1197,25 +1197,25 @@ content into your application; rather pick only the properties that you need. endpoints.trace.web.enabled= # Expose the trace endpoint as a Web endpoint. # MANAGEMENT HTTP SERVER ({sc-spring-boot-actuator}/autoconfigure/web/ManagementServerProperties.{sc-ext}[ManagementServerProperties]) - management.add-application-context-header=false # Add the "X-Application-Context" HTTP header in each response. - management.address= # Network address that the management endpoints should bind to. - management.context-path= # Management endpoint context-path. For instance `/actuator` - management.port= # Management endpoint HTTP port. Uses the same port as the application by default. Configure a different port to use management-specific SSL. - management.ssl.ciphers= # Supported SSL ciphers. Requires a custom management.port. - management.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. Requires a custom management.port. - management.ssl.enabled= # Enable SSL support. Requires a custom management.port. - management.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.port. - management.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.port. - management.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.port. - management.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file). Requires a custom management.port. - management.ssl.key-store-password= # Password used to access the key store. Requires a custom management.port. - management.ssl.key-store-provider= # Provider for the key store. Requires a custom management.port. - management.ssl.key-store-type= # Type of the key store. Requires a custom management.port. - management.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.port. - management.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.port. - management.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.port. - management.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.port. - management.ssl.trust-store-type= # Type of the trust store. Requires a custom management.port. + management.server.add-application-context-header=false # Add the "X-Application-Context" HTTP header in each response. Requires a custom management.server.port. + management.server.address= # Network address that the management endpoints should bind to. Requires a custom management.server.port. + management.server.context-path= # Management endpoint context-path. For instance `/actuator`. Requires a custom management.server.port + management.server.port= # Management endpoint HTTP port. Uses the same port as the application by default. Configure a different port to use management-specific SSL. + management.server.ssl.ciphers= # Supported SSL ciphers. Requires a custom management.port. + management.server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. Requires a custom management.server.port. + management.server.ssl.enabled= # Enable SSL support. Requires a custom management.server.port. + management.server.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.server.port. + management.server.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.server.port. + management.server.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.server.port. + management.server.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file). Requires a custom management.server.port. + management.server.ssl.key-store-password= # Password used to access the key store. Requires a custom management.server.port. + management.server.ssl.key-store-provider= # Provider for the key store. Requires a custom management.server.port. + management.server.ssl.key-store-type= # Type of the key store. Requires a custom management.server.port. + management.server.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.server.port. + management.server.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.server.port. + management.server.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.server.port. + management.server.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.server.port. + management.server.ssl.trust-store-type= # Type of the trust store. Requires a custom management.server.port. # CLOUDFOUNDRY management.cloudfoundry.enabled=true # Enable extended Cloud Foundry actuator endpoints. @@ -1229,6 +1229,9 @@ content into your application; rather pick only the properties that you need. management.endpoints.cors.exposed-headers= # Comma-separated list of headers to include in a response. management.endpoints.cors.max-age=1800 # How long, in seconds, the response from a pre-flight request can be cached by clients. + # ENDPOINTS JMX CONFIGURATION ({sc-spring-boot-actuator}/autoconfigure/endpoint/ManagementEndpointProperties.{sc-ext}[JmxEndpointExporterProperties]) + management.endpoints.web.base-path # Base path for Web endpoints. Relative to server.context-path or management.server.context-path if management.server.port is configured. + # ENDPOINTS JMX CONFIGURATION ({sc-spring-boot-actuator}/autoconfigure/endpoint/infrastructure/JmxEndpointExporterProperties.{sc-ext}[JmxEndpointExporterProperties]) management.endpoints.jmx.domain=org.springframework.boot # Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set. management.endpoints.jmx.static-names=false # Additional static properties to append to all ObjectNames of MBeans representing Endpoints. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc index 13d3f26060..0ff3aed2b7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -2116,9 +2116,9 @@ for more details. === Change the HTTP port or address of the actuator endpoints In a standalone application the Actuator HTTP port defaults to the same as the main HTTP port. To make the application listen on a different port set the external property -`management.port`. To listen on a completely different network address (e.g. if you have +`management.server.port`. To listen on a completely different network address (e.g. if you have an internal network for management and an external one for user applications) you can -also set `management.address` to a valid IP address that the server is able to bind to. +also set `management.server.address` to a valid IP address that the server is able to bind to. For more detail look at the {sc-spring-boot-actuator}/autoconfigure/web/ManagementServerProperties.{sc-ext}[`ManagementServerProperties`] diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 1c1dcddddf..9d22da44c5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -567,12 +567,12 @@ is exposed as `/application/health`. === Customizing the management endpoint paths Sometimes it is useful to customize the prefix for the management endpoints. For example, your application might already use `/application` for another purpose. -You can use the `management.context-path` property to change the prefix for your +You can use the `management.endpoints.web.base-path` property to change the prefix for your management endpoint: [source,properties,indent=0] ---- - management.context-path=/manage + management.endpoints.web.base-path=/manage ---- The `application.properties` example above will change the endpoint from `/application/{id}` to @@ -580,7 +580,8 @@ The `application.properties` example above will change the endpoint from `/appli NOTE: Unless the management port has been configured to <>, `management.context-path` is relative to `server.context-path`. +HTTP port>>, `management.endpoints.web.base-path` is relative to `server.context-path`. If `management.server.port` +is configured, `management.endpoints.web.base-path`, is relative to `management.server.context-path`. @@ -590,11 +591,11 @@ Exposing management endpoints using the default HTTP port is a sensible choice f based deployments. If, however, your application runs inside your own data center you may prefer to expose endpoints using a different HTTP port. -The `management.port` property can be used to change the HTTP port. +The `management.server.port` property can be used to change the HTTP port. [source,properties,indent=0] ---- - management.port=8081 + management.server.port=8081 ---- Since your management port is often protected by a firewall, and not exposed to the public @@ -615,7 +616,7 @@ disable the management security in this way, and it might even break the applica [[production-ready-management-specific-ssl]] === Configuring management-specific SSL When configured to use a custom port, the management server can also be configured with -its own SSL using the various `management.ssl.*` properties. For example, this allows a +its own SSL using the various `management.server.ssl.*` properties. For example, this allows a management server to be available via HTTP while the main application uses HTTPS: [source,properties,indent=0] @@ -624,8 +625,8 @@ management server to be available via HTTP while the main application uses HTTPS server.ssl.enabled=true server.ssl.key-store=classpath:store.jks server.ssl.key-password=secret - management.port=8080 - management.ssl.enabled=false + management.server.port=8080 + management.server.ssl.enabled=false ---- Alternatively, both the main server and the management server can use SSL but with @@ -637,10 +638,10 @@ different key stores: server.ssl.enabled=true server.ssl.key-store=classpath:main.jks server.ssl.key-password=secret - management.port=8080 - management.ssl.enabled=true - management.ssl.key-store=classpath:management.jks - management.ssl.key-password=secret + management.server.port=8080 + management.server.ssl.enabled=true + management.server.ssl.key-store=classpath:management.jks + management.server.ssl.key-password=secret ---- @@ -648,7 +649,7 @@ different key stores: [[production-ready-customizing-management-server-address]] === Customizing the management server address You can customize the address that the management endpoints are available on by -setting the `management.address` property. This can be useful if you want to +setting the `management.server.address` property. This can be useful if you want to listen only on an internal or ops-facing network, or to only listen for connections from `localhost`. @@ -660,8 +661,8 @@ connections: [source,properties,indent=0] ---- - management.port=8081 - management.address=127.0.0.1 + management.server.port=8081 + management.server.address=127.0.0.1 ---- @@ -672,7 +673,7 @@ If you don't want to expose endpoints over HTTP you can set the management port [source,properties,indent=0] ---- - management.port=-1 + management.server.port=-1 ---- diff --git a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/InsecureManagementPortAndPathSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/InsecureManagementPortAndPathSampleActuatorApplicationTests.java index 0ec25f7352..0729ce4ad4 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/InsecureManagementPortAndPathSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-custom-security/src/test/java/sample/actuator/customsecurity/InsecureManagementPortAndPathSampleActuatorApplicationTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port=0", "management.context-path=/admin" }) + "management.server.port=0", "management.server.context-path=/management"}) @DirtiesContext public class InsecureManagementPortAndPathSampleActuatorApplicationTests { @@ -60,7 +60,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { @Test public void testSecureActuator() throws Exception { ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/admin/health", + "http://localhost:" + this.managementPort + "/management/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @@ -68,7 +68,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { @Test public void testInsecureActuator() throws Exception { ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/admin/status", + "http://localhost:" + this.managementPort + "/management/application/status", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); @@ -78,7 +78,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { public void testMissing() throws Exception { ResponseEntity entity = new TestRestTemplate("admin", "admin") .getForEntity( - "http://localhost:" + this.managementPort + "/admin/missing", + "http://localhost:" + this.managementPort + "/management/application/missing", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getBody()).contains("\"status\":404"); diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java index 63dc25d05c..7d6e5965fe 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port:0" }) + "management.server.port:0" }) @DirtiesContext public class SampleActuatorUiApplicationPortTests { diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties index 9c3f668e0b..e184ef94a9 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties +++ b/spring-boot-samples/spring-boot-sample-actuator/src/main/resources/application.properties @@ -2,7 +2,7 @@ service.name=Phil # logging.file=/tmp/logs/app.log # logging.level.org.springframework.security=DEBUG -management.address=127.0.0.1 +management.server.address=127.0.0.1 endpoints.default.web.enabled=true endpoints.shutdown.enabled=true diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java index 8be0f0cb06..3d9b52e112 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementAddressActuatorApplicationTests.java @@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port=0", "management.address=127.0.0.1", - "management.context-path:/admin" }) + "management.server.port=0", "management.server.address=127.0.0.1", + "management.server.context-path:/admin" }) @DirtiesContext public class ManagementAddressActuatorApplicationTests { @@ -63,7 +63,7 @@ public class ManagementAddressActuatorApplicationTests { public void testHealth() throws Exception { ResponseEntity entity = new TestRestTemplate() .withBasicAuth("user", getPassword()) - .getForEntity("http://localhost:" + this.managementPort + "/admin/health", + .getForEntity("http://localhost:" + this.managementPort + "/admin/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPathSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPathSampleActuatorApplicationTests.java index 8ef544d05e..71d088f265 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPathSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPathSampleActuatorApplicationTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.context_path=/admin" }) + "management.endpoints.web.base-path=/admin" }) @DirtiesContext public class ManagementPathSampleActuatorApplicationTests { diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortAndPathSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortAndPathSampleActuatorApplicationTests.java index 90cfb8719c..64a01d48ce 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortAndPathSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortAndPathSampleActuatorApplicationTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port=0", "management.context-path=/admin" }) + "management.server.port=0", "management.endpoints.web.base-path=/admin" }) @DirtiesContext public class ManagementPortAndPathSampleActuatorApplicationTests { diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java index 769cba76ab..ea3484ee41 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port=0" }) + "management.server.port=0" }) @DirtiesContext public class ManagementPortSampleActuatorApplicationTests { diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NoManagementSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NoManagementSampleActuatorApplicationTests.java index 49cb18b92c..f2e98fb89d 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NoManagementSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NoManagementSampleActuatorApplicationTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { - "management.port=-1" }) + "management.server.port=-1" }) @DirtiesContext public class NoManagementSampleActuatorApplicationTests { diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/resources/application-endpoints.properties b/spring-boot-samples/spring-boot-sample-actuator/src/test/resources/application-endpoints.properties index d4a059f105..5731e5dadb 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/resources/application-endpoints.properties +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/resources/application-endpoints.properties @@ -1,2 +1,2 @@ server.error.path: /oops -management.context-path: /admin \ No newline at end of file +management.endpoints.web.base-path: /admin \ No newline at end of file