mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add @Conditionals to switch off non-generic endpoints
Fixes gh-601
This commit is contained in:
parent
2b185fc9c2
commit
499f54893b
@ -45,6 +45,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|||||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
@ -147,18 +148,21 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(EnvironmentEndpoint.class)
|
@ConditionalOnBean(EnvironmentEndpoint.class)
|
||||||
|
@ConditionalOnExpression("${endpoints.env.enabled:true}")
|
||||||
public EnvironmentMvcEndpoint environmentMvcEndpoint(EnvironmentEndpoint delegate) {
|
public EnvironmentMvcEndpoint environmentMvcEndpoint(EnvironmentEndpoint delegate) {
|
||||||
return new EnvironmentMvcEndpoint(delegate);
|
return new EnvironmentMvcEndpoint(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(MetricsEndpoint.class)
|
@ConditionalOnBean(MetricsEndpoint.class)
|
||||||
|
@ConditionalOnExpression("${endpoints.metrics.enabled:true}")
|
||||||
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
|
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
|
||||||
return new MetricsMvcEndpoint(delegate);
|
return new MetricsMvcEndpoint(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(ShutdownEndpoint.class)
|
@ConditionalOnBean(ShutdownEndpoint.class)
|
||||||
|
@ConditionalOnExpression("${endpoints.shutdown.enabled:false}")
|
||||||
public ShutdownMvcEndpoint shutdownMvcEndpoint(ShutdownEndpoint delegate) {
|
public ShutdownMvcEndpoint shutdownMvcEndpoint(ShutdownEndpoint delegate) {
|
||||||
return new ShutdownMvcEndpoint(delegate);
|
return new ShutdownMvcEndpoint(delegate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user