Commit d307eba0 authored by Madhura Bhave's avatar Madhura Bhave

Add property to configure base-path for web endpoints.

Also, move properties corresponding to management server under
`management.server.*`.

Closes gh-10230
parent 68db43cf
...@@ -21,7 +21,6 @@ import java.util.List; ...@@ -21,7 +21,6 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; 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.EndpointInfo;
import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation;
import org.springframework.util.Assert; import org.springframework.util.Assert;
...@@ -36,12 +35,12 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider { ...@@ -36,12 +35,12 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider {
private final Collection<EndpointInfo<WebEndpointOperation>> endpoints; private final Collection<EndpointInfo<WebEndpointOperation>> endpoints;
private final String contextPath; private final String basePath;
public DefaultEndpointPathProvider(EndpointProvider<WebEndpointOperation> provider, public DefaultEndpointPathProvider(EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
this.endpoints = provider.getEndpoints(); this.endpoints = provider.getEndpoints();
this.contextPath = managementServerProperties.getContextPath(); this.basePath = webEndpointProperties.getBasePath();
} }
@Override @Override
...@@ -57,7 +56,7 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider { ...@@ -57,7 +56,7 @@ public class DefaultEndpointPathProvider implements EndpointPathProvider {
} }
private String getPath(EndpointInfo<WebEndpointOperation> endpointInfo) { private String getPath(EndpointInfo<WebEndpointOperation> endpointInfo) {
return this.contextPath + "/" + endpointInfo.getId(); return this.basePath + "/" + endpointInfo.getId();
} }
} }
/*
* 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;
}
}
...@@ -23,8 +23,8 @@ import org.glassfish.jersey.server.ResourceConfig; ...@@ -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.EndpointProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; 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.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.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation;
import org.springframework.boot.actuate.endpoint.web.jersey.JerseyEndpointResourceFactory; import org.springframework.boot.actuate.endpoint.web.jersey.JerseyEndpointResourceFactory;
...@@ -55,10 +55,10 @@ class JerseyWebEndpointManagementContextConfiguration { ...@@ -55,10 +55,10 @@ class JerseyWebEndpointManagementContextConfiguration {
@Bean @Bean
public ResourceConfigCustomizer webEndpointRegistrar( public ResourceConfigCustomizer webEndpointRegistrar(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
return (resourceConfig) -> resourceConfig.registerResources( return (resourceConfig) -> resourceConfig.registerResources(
new HashSet<>(new JerseyEndpointResourceFactory().createEndpointResources( new HashSet<>(new JerseyEndpointResourceFactory().createEndpointResources(
new EndpointMapping(managementServerProperties.getContextPath()), new EndpointMapping(webEndpointProperties.getBasePath()),
provider.getEndpoints()))); provider.getEndpoints())));
} }
...@@ -66,8 +66,8 @@ class JerseyWebEndpointManagementContextConfiguration { ...@@ -66,8 +66,8 @@ class JerseyWebEndpointManagementContextConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public EndpointPathProvider endpointPathProvider( public EndpointPathProvider endpointPathProvider(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
return new DefaultEndpointPathProvider(provider, managementServerProperties); return new DefaultEndpointPathProvider(provider, webEndpointProperties);
} }
} }
...@@ -19,8 +19,8 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive; ...@@ -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.EndpointProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; 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.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.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation;
import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping; import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping;
...@@ -45,9 +45,9 @@ public class WebFluxEndpointManagementContextConfiguration { ...@@ -45,9 +45,9 @@ public class WebFluxEndpointManagementContextConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping( public WebFluxEndpointHandlerMapping webEndpointReactiveHandlerMapping(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
return new WebFluxEndpointHandlerMapping( return new WebFluxEndpointHandlerMapping(
new EndpointMapping(managementServerProperties.getContextPath()), new EndpointMapping(webEndpointProperties.getBasePath()),
provider.getEndpoints()); provider.getEndpoints());
} }
...@@ -55,8 +55,8 @@ public class WebFluxEndpointManagementContextConfiguration { ...@@ -55,8 +55,8 @@ public class WebFluxEndpointManagementContextConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public EndpointPathProvider endpointPathProvider( public EndpointPathProvider endpointPathProvider(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
return new DefaultEndpointPathProvider(provider, managementServerProperties); return new DefaultEndpointPathProvider(provider, webEndpointProperties);
} }
} }
...@@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet; ...@@ -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.EndpointProvider;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.DefaultEndpointPathProvider; 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.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.ManagementContextConfiguration;
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
...@@ -48,7 +49,7 @@ import org.springframework.web.servlet.DispatcherServlet; ...@@ -48,7 +49,7 @@ import org.springframework.web.servlet.DispatcherServlet;
@ConditionalOnClass(DispatcherServlet.class) @ConditionalOnClass(DispatcherServlet.class)
@ConditionalOnBean(DispatcherServlet.class) @ConditionalOnBean(DispatcherServlet.class)
@EnableConfigurationProperties({ CorsEndpointProperties.class, @EnableConfigurationProperties({ CorsEndpointProperties.class,
ManagementServerProperties.class }) WebEndpointProperties.class, ManagementServerProperties.class })
public class WebMvcEndpointManagementContextConfiguration { public class WebMvcEndpointManagementContextConfiguration {
@Bean @Bean
...@@ -56,9 +57,9 @@ public class WebMvcEndpointManagementContextConfiguration { ...@@ -56,9 +57,9 @@ public class WebMvcEndpointManagementContextConfiguration {
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping( public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
CorsEndpointProperties corsProperties, CorsEndpointProperties corsProperties,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
WebMvcEndpointHandlerMapping handlerMapping = new WebMvcEndpointHandlerMapping( WebMvcEndpointHandlerMapping handlerMapping = new WebMvcEndpointHandlerMapping(
new EndpointMapping(managementServerProperties.getContextPath()), new EndpointMapping(webEndpointProperties.getBasePath()),
provider.getEndpoints(), getCorsConfiguration(corsProperties)); provider.getEndpoints(), getCorsConfiguration(corsProperties));
return handlerMapping; return handlerMapping;
} }
...@@ -67,8 +68,8 @@ public class WebMvcEndpointManagementContextConfiguration { ...@@ -67,8 +68,8 @@ public class WebMvcEndpointManagementContextConfiguration {
@ConditionalOnMissingBean @ConditionalOnMissingBean
public EndpointPathProvider endpointPathProvider( public EndpointPathProvider endpointPathProvider(
EndpointProvider<WebEndpointOperation> provider, EndpointProvider<WebEndpointOperation> provider,
ManagementServerProperties managementServerProperties) { WebEndpointProperties webEndpointProperties) {
return new DefaultEndpointPathProvider(provider, managementServerProperties); return new DefaultEndpointPathProvider(provider, webEndpointProperties);
} }
private CorsConfiguration getCorsConfiguration(CorsEndpointProperties properties) { private CorsConfiguration getCorsConfiguration(CorsEndpointProperties properties) {
......
...@@ -69,7 +69,7 @@ public class JolokiaManagementContextConfiguration { ...@@ -69,7 +69,7 @@ public class JolokiaManagementContextConfiguration {
@Bean @Bean
public ServletRegistrationBean<AgentServlet> jolokiaServlet() { public ServletRegistrationBean<AgentServlet> jolokiaServlet() {
String path = this.managementServletContext.getContextPath() String path = this.managementServletContext.getServletPath()
+ this.properties.getPath(); + this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
ServletRegistrationBean<AgentServlet> registration = new ServletRegistrationBean<>( ServletRegistrationBean<AgentServlet> registration = new ServletRegistrationBean<>(
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.autoconfigure.web.server; package org.springframework.boot.actuate.autoconfigure.web.server;
import org.springframework.beans.factory.SmartInitializingSingleton; 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.ManagementContextFactory;
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType;
import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.AutoConfigureOrder;
...@@ -42,8 +43,8 @@ import org.springframework.web.context.ConfigurableWebApplicationContext; ...@@ -42,8 +43,8 @@ import org.springframework.web.context.ConfigurableWebApplicationContext;
/** /**
* {@link EnableAutoConfiguration Auto-configuration} for the management context. If the * {@link EnableAutoConfiguration Auto-configuration} for the management context. If the
* {@code management.port} is the same as the {@code server.port} the management context * {@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.port} is * 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 * different to the {@code server.port} the management context will be a separate context
* that has the main application context as its parent. * that has the main application context as its parent.
* *
...@@ -52,7 +53,7 @@ import org.springframework.web.context.ConfigurableWebApplicationContext; ...@@ -52,7 +53,7 @@ import org.springframework.web.context.ConfigurableWebApplicationContext;
*/ */
@Configuration @Configuration
@AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE)
@EnableConfigurationProperties(ManagementServerProperties.class) @EnableConfigurationProperties({ WebEndpointProperties.class, ManagementServerProperties.class })
public class ManagementContextAutoConfiguration { public class ManagementContextAutoConfiguration {
@Configuration @Configuration
...@@ -76,7 +77,7 @@ public class ManagementContextAutoConfiguration { ...@@ -76,7 +77,7 @@ public class ManagementContextAutoConfiguration {
} }
private void verifySslConfiguration() { private void verifySslConfiguration() {
Boolean enabled = this.environment.getProperty("management.ssl.enabled", Boolean enabled = this.environment.getProperty("management.server.ssl.enabled",
Boolean.class, false); Boolean.class, false);
Assert.state(!enabled, Assert.state(!enabled,
"Management-specific SSL cannot be configured as the management " "Management-specific SSL cannot be configured as the management "
......
...@@ -43,7 +43,7 @@ public enum ManagementPortType { ...@@ -43,7 +43,7 @@ public enum ManagementPortType {
static ManagementPortType get(Environment environment) { static ManagementPortType get(Environment environment) {
Integer serverPort = getPortProperty(environment, "server."); Integer serverPort = getPortProperty(environment, "server.");
Integer managementPort = getPortProperty(environment, "management."); Integer managementPort = getPortProperty(environment, "management.server.");
if (managementPort != null && managementPort < 0) { if (managementPort != null && managementPort < 0) {
return DISABLED; return DISABLED;
} }
......
...@@ -35,7 +35,7 @@ import org.springframework.util.StringUtils; ...@@ -35,7 +35,7 @@ import org.springframework.util.StringUtils;
* @since 2.0.0 * @since 2.0.0
* @see ServerProperties * @see ServerProperties
*/ */
@ConfigurationProperties(prefix = "management", ignoreUnknownFields = true) @ConfigurationProperties(prefix = "management.server", ignoreUnknownFields = true)
public class ManagementServerProperties implements SecurityPrerequisite { public class ManagementServerProperties implements SecurityPrerequisite {
/** /**
...@@ -54,7 +54,7 @@ public class ManagementServerProperties implements SecurityPrerequisite { ...@@ -54,7 +54,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/** /**
* Management endpoint context-path. * Management endpoint context-path.
*/ */
private String contextPath = "/application"; private String contextPath = "";
/** /**
* Add the "X-Application-Context" HTTP header in each response. * Add the "X-Application-Context" HTTP header in each response.
......
...@@ -20,15 +20,16 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet; ...@@ -20,15 +20,16 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet;
* Provides information about the management servlet context for MVC controllers to use. * Provides information about the management servlet context for MVC controllers to use.
* *
* @author Phillip Webb * @author Phillip Webb
* @author Madhura Bhave
* @since 2.0.0 * @since 2.0.0
*/ */
@FunctionalInterface @FunctionalInterface
public interface ManagementServletContext { public interface ManagementServletContext {
/** /**
* Return the context path of the management server. * Return the servlet path of the management server.
* @return the context path * @return the servlet path
*/ */
String getContextPath(); String getServletPath();
} }
...@@ -102,7 +102,7 @@ class ServletManagementChildContextConfiguration { ...@@ -102,7 +102,7 @@ class ServletManagementChildContextConfiguration {
ServerProperties serverProperties) { ServerProperties serverProperties) {
super.customize(webServerFactory, managementServerProperties, super.customize(webServerFactory, managementServerProperties,
serverProperties); serverProperties);
webServerFactory.setContextPath(""); webServerFactory.setContextPath(managementServerProperties.getContextPath());
} }
} }
......
...@@ -18,7 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet; ...@@ -18,7 +18,7 @@ package org.springframework.boot.actuate.autoconfigure.web.servlet;
import javax.servlet.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.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
...@@ -48,8 +48,8 @@ public class ServletManagementContextAutoConfiguration { ...@@ -48,8 +48,8 @@ public class ServletManagementContextAutoConfiguration {
@Bean @Bean
public ManagementServletContext managementServletContext( public ManagementServletContext managementServletContext(
ManagementServerProperties properties) { WebEndpointProperties properties) {
return () -> properties.getContextPath(); return () -> properties.getBasePath();
} }
// Put Servlets and Filters in their own nested class so they don't force early // Put Servlets and Filters in their own nested class so they don't force early
......
...@@ -26,7 +26,6 @@ import org.mockito.Mock; ...@@ -26,7 +26,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointProvider; 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.DefaultEnablement;
import org.springframework.boot.actuate.endpoint.EndpointInfo; import org.springframework.boot.actuate.endpoint.EndpointInfo;
import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation; import org.springframework.boot.actuate.endpoint.web.WebEndpointOperation;
...@@ -88,10 +87,10 @@ public class DefaultEndpointPathProviderTests { ...@@ -88,10 +87,10 @@ public class DefaultEndpointPathProviderTests {
endpoints.add(new EndpointInfo<>("bar", DefaultEnablement.ENABLED, endpoints.add(new EndpointInfo<>("bar", DefaultEnablement.ENABLED,
Collections.emptyList())); Collections.emptyList()));
given(this.endpointProvider.getEndpoints()).willReturn(endpoints); given(this.endpointProvider.getEndpoints()).willReturn(endpoints);
ManagementServerProperties managementServerProperties = new ManagementServerProperties(); WebEndpointProperties webEndpointProperties = new WebEndpointProperties();
managementServerProperties.setContextPath(contextPath); webEndpointProperties.setBasePath(contextPath);
return new DefaultEndpointPathProvider(this.endpointProvider, return new DefaultEndpointPathProvider(this.endpointProvider,
managementServerProperties); webEndpointProperties);
} }
} }
/*
* 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");
}
}
...@@ -74,10 +74,10 @@ public class WebMvcEndpointIntegrationTests { ...@@ -74,10 +74,10 @@ public class WebMvcEndpointIntegrationTests {
} }
@Test @Test
public void endpointsAreSecureByDefaultWithCustomContextPath() throws Exception { public void endpointsAreSecureByDefaultWithCustomBasePath() throws Exception {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
TestPropertyValues.of("management.context-path:/management") TestPropertyValues.of("management.endpoints.web.base-path:/management")
.applyTo(this.context); .applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans").accept(MediaType.APPLICATION_JSON)) mockMvc.perform(get("/management/beans").accept(MediaType.APPLICATION_JSON))
...@@ -85,13 +85,13 @@ public class WebMvcEndpointIntegrationTests { ...@@ -85,13 +85,13 @@ public class WebMvcEndpointIntegrationTests {
} }
@Test @Test
public void endpointsAreSecureWithActuatorRoleWithCustomContextPath() public void endpointsAreSecureWithActuatorRoleWithCustomBasePath()
throws Exception { throws Exception {
TestSecurityContextHolder.getContext().setAuthentication( TestSecurityContextHolder.getContext().setAuthentication(
new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); 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); "endpoints.default.web.enabled=true").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
......
...@@ -76,7 +76,7 @@ public class JolokiaManagementContextConfigurationTests { ...@@ -76,7 +76,7 @@ public class JolokiaManagementContextConfigurationTests {
public void customManagementPath() { public void customManagementPath() {
this.contextRunner this.contextRunner
.withPropertyValues("management.jolokia.enabled=true", .withPropertyValues("management.jolokia.enabled=true",
"management.context-path=/admin") "management.endpoints.web.base-path=/admin")
.run(isDefinedOnPath("/admin/jolokia/*")); .run(isDefinedOnPath("/admin/jolokia/*"));
} }
......
...@@ -46,7 +46,7 @@ public class ManagementServerPropertiesTests { ...@@ -46,7 +46,7 @@ public class ManagementServerPropertiesTests {
public void defaultManagementServerProperties() { public void defaultManagementServerProperties() {
ManagementServerProperties properties = new ManagementServerProperties(); ManagementServerProperties properties = new ManagementServerProperties();
assertThat(properties.getPort()).isNull(); assertThat(properties.getPort()).isNull();
assertThat(properties.getContextPath()).isEqualTo("/application"); assertThat(properties.getContextPath()).isEqualTo("");
assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false); assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false);
} }
......
...@@ -1197,25 +1197,25 @@ content into your application; rather pick only the properties that you need. ...@@ -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. 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 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.server.add-application-context-header=false # Add the "X-Application-Context" HTTP header in each response. Requires a custom management.server.port.
management.address= # Network address that the management endpoints should bind to. management.server.address= # Network address that the management endpoints should bind to. Requires a custom management.server.port.
management.context-path= # Management endpoint context-path. For instance `/actuator` management.server.context-path= # Management endpoint context-path. For instance `/actuator`. Requires a custom management.server.port
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.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.ssl.ciphers= # Supported SSL ciphers. Requires a custom management.port. management.server.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.server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. Requires a custom management.server.port.
management.ssl.enabled= # Enable SSL support. Requires a custom management.port. management.server.ssl.enabled= # Enable SSL support. Requires a custom management.server.port.
management.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.port. management.server.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.server.port.
management.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.port. management.server.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.server.port.
management.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.port. management.server.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.server.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.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.ssl.key-store-password= # Password used to access the key store. Requires a custom management.port. management.server.ssl.key-store-password= # Password used to access the key store. Requires a custom management.server.port.
management.ssl.key-store-provider= # Provider for the key store. Requires a custom management.port. management.server.ssl.key-store-provider= # Provider for the key store. Requires a custom management.server.port.
management.ssl.key-store-type= # Type of the key store. Requires a custom management.port. management.server.ssl.key-store-type= # Type of the key store. Requires a custom management.server.port.
management.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.port. management.server.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.server.port.
management.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.port. management.server.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.server.port.
management.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.port. management.server.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.server.port.
management.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.port. management.server.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.server.port.
management.ssl.trust-store-type= # Type of the trust store. Requires a custom management.port. management.server.ssl.trust-store-type= # Type of the trust store. Requires a custom management.server.port.
# CLOUDFOUNDRY # CLOUDFOUNDRY
management.cloudfoundry.enabled=true # Enable extended Cloud Foundry actuator endpoints. 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. ...@@ -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.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. 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]) # 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.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. management.endpoints.jmx.static-names=false # Additional static properties to append to all ObjectNames of MBeans representing Endpoints.
......
...@@ -2116,9 +2116,9 @@ for more details. ...@@ -2116,9 +2116,9 @@ for more details.
=== Change the HTTP port or address of the actuator endpoints === 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 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 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 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 For more detail look at the
{sc-spring-boot-actuator}/autoconfigure/web/ManagementServerProperties.{sc-ext}[`ManagementServerProperties`] {sc-spring-boot-actuator}/autoconfigure/web/ManagementServerProperties.{sc-ext}[`ManagementServerProperties`]
......
...@@ -567,12 +567,12 @@ is exposed as `/application/health`. ...@@ -567,12 +567,12 @@ is exposed as `/application/health`.
=== Customizing the management endpoint paths === Customizing the management endpoint paths
Sometimes it is useful to customize the prefix for the management endpoints. Sometimes it is useful to customize the prefix for the management endpoints.
For example, your application might already use `/application` for another purpose. 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: management endpoint:
[source,properties,indent=0] [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 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 ...@@ -580,7 +580,8 @@ The `application.properties` example above will change the endpoint from `/appli
NOTE: Unless the management port has been configured to NOTE: Unless the management port has been configured to
<<production-ready-customizing-management-server-port,expose endpoints using a different <<production-ready-customizing-management-server-port,expose endpoints using a different
HTTP port>>, `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 ...@@ -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 based deployments. If, however, your application runs inside your own data center you
may prefer to expose endpoints using a different HTTP port. 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] [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 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 ...@@ -615,7 +616,7 @@ disable the management security in this way, and it might even break the applica
[[production-ready-management-specific-ssl]] [[production-ready-management-specific-ssl]]
=== Configuring management-specific SSL === Configuring management-specific SSL
When configured to use a custom port, the management server can also be configured with 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: management server to be available via HTTP while the main application uses HTTPS:
[source,properties,indent=0] [source,properties,indent=0]
...@@ -624,8 +625,8 @@ management server to be available via HTTP while the main application uses HTTPS ...@@ -624,8 +625,8 @@ management server to be available via HTTP while the main application uses HTTPS
server.ssl.enabled=true server.ssl.enabled=true
server.ssl.key-store=classpath:store.jks server.ssl.key-store=classpath:store.jks
server.ssl.key-password=secret server.ssl.key-password=secret
management.port=8080 management.server.port=8080
management.ssl.enabled=false management.server.ssl.enabled=false
---- ----
Alternatively, both the main server and the management server can use SSL but with Alternatively, both the main server and the management server can use SSL but with
...@@ -637,10 +638,10 @@ different key stores: ...@@ -637,10 +638,10 @@ different key stores:
server.ssl.enabled=true server.ssl.enabled=true
server.ssl.key-store=classpath:main.jks server.ssl.key-store=classpath:main.jks
server.ssl.key-password=secret server.ssl.key-password=secret
management.port=8080 management.server.port=8080
management.ssl.enabled=true management.server.ssl.enabled=true
management.ssl.key-store=classpath:management.jks management.server.ssl.key-store=classpath:management.jks
management.ssl.key-password=secret management.server.ssl.key-password=secret
---- ----
...@@ -648,7 +649,7 @@ different key stores: ...@@ -648,7 +649,7 @@ different key stores:
[[production-ready-customizing-management-server-address]] [[production-ready-customizing-management-server-address]]
=== Customizing the management server address === Customizing the management server address
You can customize the address that the management endpoints are available on by 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 listen only on an internal or ops-facing network, or to only listen for connections from
`localhost`. `localhost`.
...@@ -660,8 +661,8 @@ connections: ...@@ -660,8 +661,8 @@ connections:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.port=8081 management.server.port=8081
management.address=127.0.0.1 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 ...@@ -672,7 +673,7 @@ If you don't want to expose endpoints over HTTP you can set the management port
[source,properties,indent=0] [source,properties,indent=0]
---- ----
management.port=-1 management.server.port=-1
---- ----
......
...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.context-path=/admin" }) "management.server.port=0", "management.server.context-path=/management"})
@DirtiesContext @DirtiesContext
public class InsecureManagementPortAndPathSampleActuatorApplicationTests { public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
...@@ -60,7 +60,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { ...@@ -60,7 +60,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@Test @Test
public void testSecureActuator() throws Exception { public void testSecureActuator() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity( ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/health", "http://localhost:" + this.managementPort + "/management/application/health",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
} }
...@@ -68,7 +68,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { ...@@ -68,7 +68,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@Test @Test
public void testInsecureActuator() throws Exception { public void testInsecureActuator() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity( ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/status", "http://localhost:" + this.managementPort + "/management/application/status",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\""); assertThat(entity.getBody()).contains("\"status\":\"UP\"");
...@@ -78,7 +78,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests { ...@@ -78,7 +78,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
public void testMissing() throws Exception { public void testMissing() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate("admin", "admin") ResponseEntity<String> entity = new TestRestTemplate("admin", "admin")
.getForEntity( .getForEntity(
"http://localhost:" + this.managementPort + "/admin/missing", "http://localhost:" + this.managementPort + "/management/application/missing",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(entity.getBody()).contains("\"status\":404"); assertThat(entity.getBody()).contains("\"status\":404");
......
...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port:0" }) "management.server.port:0" })
@DirtiesContext @DirtiesContext
public class SampleActuatorUiApplicationPortTests { public class SampleActuatorUiApplicationPortTests {
......
...@@ -2,7 +2,7 @@ service.name=Phil ...@@ -2,7 +2,7 @@ service.name=Phil
# logging.file=/tmp/logs/app.log # logging.file=/tmp/logs/app.log
# logging.level.org.springframework.security=DEBUG # 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.default.web.enabled=true
endpoints.shutdown.enabled=true endpoints.shutdown.enabled=true
......
...@@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.address=127.0.0.1", "management.server.port=0", "management.server.address=127.0.0.1",
"management.context-path:/admin" }) "management.server.context-path:/admin" })
@DirtiesContext @DirtiesContext
public class ManagementAddressActuatorApplicationTests { public class ManagementAddressActuatorApplicationTests {
...@@ -63,7 +63,7 @@ public class ManagementAddressActuatorApplicationTests { ...@@ -63,7 +63,7 @@ public class ManagementAddressActuatorApplicationTests {
public void testHealth() throws Exception { public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate() ResponseEntity<String> entity = new TestRestTemplate()
.withBasicAuth("user", getPassword()) .withBasicAuth("user", getPassword())
.getForEntity("http://localhost:" + this.managementPort + "/admin/health", .getForEntity("http://localhost:" + this.managementPort + "/admin/application/health",
String.class); String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\""); assertThat(entity.getBody()).contains("\"status\":\"UP\"");
......
...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.context_path=/admin" }) "management.endpoints.web.base-path=/admin" })
@DirtiesContext @DirtiesContext
public class ManagementPathSampleActuatorApplicationTests { public class ManagementPathSampleActuatorApplicationTests {
......
...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.context-path=/admin" }) "management.server.port=0", "management.endpoints.web.base-path=/admin" })
@DirtiesContext @DirtiesContext
public class ManagementPortAndPathSampleActuatorApplicationTests { public class ManagementPortAndPathSampleActuatorApplicationTests {
......
...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0" }) "management.server.port=0" })
@DirtiesContext @DirtiesContext
public class ManagementPortSampleActuatorApplicationTests { public class ManagementPortSampleActuatorApplicationTests {
......
...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=-1" }) "management.server.port=-1" })
@DirtiesContext @DirtiesContext
public class NoManagementSampleActuatorApplicationTests { public class NoManagementSampleActuatorApplicationTests {
......
server.error.path: /oops server.error.path: /oops
management.context-path: /admin management.endpoints.web.base-path: /admin
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment