mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Replace @ConditionalOnExpression with OnProperty
Replace where possible all @ConditionalOnExpression annotations with @ConditionalOnProperty which is both faster to run and more descriptive. Fixes gh-1685
This commit is contained in:
parent
7b33f286f5
commit
dca637f51f
@ -54,8 +54,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -124,21 +124,21 @@ public class CrshAutoConfiguration {
|
||||
private ShellProperties properties;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnExpression("'${shell.auth:simple}' == 'jaas'")
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "jaas")
|
||||
@ConditionalOnMissingBean({ CrshShellAuthenticationProperties.class })
|
||||
public CrshShellAuthenticationProperties jaasAuthenticationProperties() {
|
||||
return new JaasAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnExpression("'${shell.auth:simple}' == 'key'")
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "key")
|
||||
@ConditionalOnMissingBean({ CrshShellAuthenticationProperties.class })
|
||||
public CrshShellAuthenticationProperties keyAuthenticationProperties() {
|
||||
return new KeyAuthenticationProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnExpression("'${shell.auth:simple}' == 'simple'")
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "simple", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean({ CrshShellAuthenticationProperties.class })
|
||||
public CrshShellAuthenticationProperties simpleAuthenticationProperties() {
|
||||
return new SimpleAuthenticationProperties();
|
||||
@ -156,7 +156,7 @@ public class CrshAutoConfiguration {
|
||||
* Class to configure CRaSH to authenticate against Spring Security.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnExpression("'${shell.auth:spring}' == 'spring'")
|
||||
@ConditionalOnProperty(prefix = "shell", name = "auth", havingValue = "spring", matchIfMissing = true)
|
||||
@ConditionalOnBean({ AuthenticationManager.class })
|
||||
@AutoConfigureAfter(CrshAutoConfiguration.class)
|
||||
public static class AuthenticationManagerAdapterAutoConfiguration {
|
||||
|
@ -23,12 +23,16 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
import org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -67,4 +71,21 @@ public class EndpointMBeanExportAutoConfiguration {
|
||||
public MBeanServer mbeanServer() {
|
||||
return new JmxAutoConfiguration().mbeanServer();
|
||||
}
|
||||
}
|
||||
|
||||
static class JmxCondition extends SpringBootCondition {
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String endpointEnabled = context.getEnvironment().getProperty(
|
||||
"endpoints.jmx.enabled", "true");
|
||||
String jmxEnabled = context.getEnvironment().getProperty(
|
||||
"spring.jmx.enabled", "true");
|
||||
return new ConditionOutcome("true".equalsIgnoreCase(endpointEnabled)
|
||||
&& "true".equalsIgnoreCase(jmxEnabled),
|
||||
"JMX endpoint and JMX enabled");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
@ -146,14 +146,14 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(EnvironmentEndpoint.class)
|
||||
@ConditionalOnExpression("${endpoints.env.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "endpoints.env", name = "enabled", matchIfMissing = true)
|
||||
public EnvironmentMvcEndpoint environmentMvcEndpoint(EnvironmentEndpoint delegate) {
|
||||
return new EnvironmentMvcEndpoint(delegate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(HealthEndpoint.class)
|
||||
@ConditionalOnExpression("${endpoints.health.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "endpoints.health", name = "enabled", matchIfMissing = true)
|
||||
public HealthMvcEndpoint healthMvcEndpoint(HealthEndpoint delegate) {
|
||||
HealthMvcEndpoint healthMvcEndpoint = new HealthMvcEndpoint(delegate);
|
||||
if (this.healthMvcEndpointProperties.getMapping() != null) {
|
||||
@ -165,14 +165,14 @@ public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(MetricsEndpoint.class)
|
||||
@ConditionalOnExpression("${endpoints.metrics.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "endpoints.metrics", name = "enabled", matchIfMissing = true)
|
||||
public MetricsMvcEndpoint metricsMvcEndpoint(MetricsEndpoint delegate) {
|
||||
return new MetricsMvcEndpoint(delegate);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(ShutdownEndpoint.class)
|
||||
@ConditionalOnExpression("${endpoints.shutdown.enabled:false}")
|
||||
@ConditionalOnProperty(prefix = "endpoints.shutdown", name = "enabled", matchIfMissing = true)
|
||||
public ShutdownMvcEndpoint shutdownMvcEndpoint(ShutdownEndpoint delegate) {
|
||||
return new ShutdownMvcEndpoint(delegate);
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadata;
|
||||
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider;
|
||||
@ -96,7 +96,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(DataSource.class)
|
||||
@ConditionalOnExpression("${health.db.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.db", name = "enabled", matchIfMissing = true)
|
||||
public static class DataSourcesHealthIndicatorConfiguration {
|
||||
|
||||
@Autowired
|
||||
@ -143,7 +143,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(MongoTemplate.class)
|
||||
@ConditionalOnExpression("${health.mongo.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.mongo", name = "enabled", matchIfMissing = true)
|
||||
public static class MongoHealthIndicatorConfiguration {
|
||||
|
||||
@Autowired
|
||||
@ -172,7 +172,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(RedisConnectionFactory.class)
|
||||
@ConditionalOnExpression("${health.redis.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.redis", name = "enabled", matchIfMissing = true)
|
||||
public static class RedisHealthIndicatorConfiguration {
|
||||
|
||||
@Autowired
|
||||
@ -202,7 +202,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(RabbitTemplate.class)
|
||||
@ConditionalOnExpression("${health.rabbit.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.rabbit", name = "enabled", matchIfMissing = true)
|
||||
public static class RabbitHealthIndicatorConfiguration {
|
||||
|
||||
@Autowired
|
||||
@ -232,7 +232,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnBean(SolrServer.class)
|
||||
@ConditionalOnExpression("${health.solr.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.solr", name = "enabled", matchIfMissing = true)
|
||||
public static class SolrHealthIndicatorConfiguration {
|
||||
|
||||
@Autowired
|
||||
@ -260,7 +260,7 @@ public class HealthIndicatorAutoConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnExpression("${health.diskspace.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "health.diskspace", name = "enabled", matchIfMissing = true)
|
||||
public static class DiskSpaceHealthIndicatorConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -25,8 +25,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
@ -54,7 +54,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@Configuration
|
||||
@ConditionalOnWebApplication
|
||||
@ConditionalOnClass({ AgentServlet.class })
|
||||
@ConditionalOnExpression("${endpoints.jolokia.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "endpoints.jolokia", name = "enabled", matchIfMissing = true)
|
||||
@AutoConfigureBefore(ManagementSecurityAutoConfiguration.class)
|
||||
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
|
||||
@EnableConfigurationProperties(JolokiaProperties.class)
|
||||
|
@ -30,10 +30,12 @@ import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
import org.springframework.boot.autoconfigure.security.AuthenticationManagerConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||
@ -44,8 +46,11 @@ import org.springframework.boot.autoconfigure.web.ErrorController;
|
||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||
@ -165,16 +170,35 @@ public class ManagementSecurityAutoConfiguration {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnExpression("${management.security.enabled:true} && !${security.basic.enabled:true}")
|
||||
@ConditionalOnMissingBean(WebSecurityConfiguration.class)
|
||||
@ConditionalOnWebApplication
|
||||
@Conditional(WebSecurityEnablerCondition.class)
|
||||
@EnableWebSecurity
|
||||
protected static class WebSecurityEnabler extends AuthenticationManagerConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* WebSecurityEnabler condition
|
||||
*/
|
||||
static class WebSecurityEnablerCondition extends SpringBootCondition {
|
||||
|
||||
@Override
|
||||
public ConditionOutcome getMatchOutcome(ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String managementEnabled = context.getEnvironment().getProperty(
|
||||
"management.security.enabled", "true");
|
||||
String basicEnabled = context.getEnvironment().getProperty(
|
||||
"security.basic.enabled", "true");
|
||||
return new ConditionOutcome("true".equalsIgnoreCase(managementEnabled)
|
||||
&& !"true".equalsIgnoreCase(basicEnabled),
|
||||
"Management security enabled and basic disabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnMissingBean({ ManagementWebSecurityConfigurerAdapter.class })
|
||||
@ConditionalOnExpression("${management.security.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "management.security", name = "enabled", matchIfMissing = true)
|
||||
@ConditionalOnWebApplication
|
||||
@Order(ManagementServerProperties.BASIC_AUTH_ORDER)
|
||||
protected static class ManagementWebSecurityConfigurerAdapter extends
|
||||
|
@ -25,8 +25,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -80,7 +80,7 @@ import com.rabbitmq.client.Channel;
|
||||
public class RabbitAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnExpression("${spring.rabbitmq.dynamic:true}")
|
||||
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "dynamic", matchIfMissing = true)
|
||||
@ConditionalOnMissingBean(AmqpAdmin.class)
|
||||
public AmqpAdmin amqpAdmin(CachingConnectionFactory connectionFactory) {
|
||||
return new RabbitAdmin(connectionFactory);
|
||||
|
@ -94,7 +94,7 @@ public @interface ConditionalOnProperty {
|
||||
String prefix() default "";
|
||||
|
||||
/**
|
||||
* The name of the properties to test.If a prefix has been defined, it is applied to
|
||||
* The name of the properties to test. If a prefix has been defined, it is applied to
|
||||
* compute the full key of each property. For instance if the prefix is
|
||||
* {@code app.config} and one value is {@code my-value}, the fully key would be
|
||||
* {@code app.config.my-value}
|
||||
|
@ -26,8 +26,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@ -51,7 +51,7 @@ import org.springframework.util.Assert;
|
||||
@Configuration
|
||||
@ConditionalOnClass(Flyway.class)
|
||||
@ConditionalOnBean(DataSource.class)
|
||||
@ConditionalOnExpression("${flyway.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "flyway", name = "enabled", matchIfMissing = true)
|
||||
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||
public class FlywayAutoConfiguration {
|
||||
|
||||
|
@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.EntityManagerFactoryDependsOnPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||
@ -54,7 +54,7 @@ import org.springframework.util.Assert;
|
||||
@Configuration
|
||||
@ConditionalOnClass(SpringLiquibase.class)
|
||||
@ConditionalOnBean(DataSource.class)
|
||||
@ConditionalOnExpression("${liquibase.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "liquibase", name = "enabled", matchIfMissing = true)
|
||||
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
|
||||
public class LiquibaseAutoConfiguration {
|
||||
|
||||
|
@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.security;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration;
|
||||
@ -35,7 +35,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@ConditionalOnExpression("!${security.basic.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "security.basic", name = "enabled", havingValue = "false")
|
||||
@ConditionalOnBean(WebSecurityConfigurerAdapter.class)
|
||||
@ConditionalOnClass(EnableWebSecurity.class)
|
||||
@ConditionalOnMissingBean(WebSecurityConfiguration.class)
|
||||
|
@ -25,9 +25,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
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.ConditionalOnMissingClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.security.SecurityProperties.Headers;
|
||||
import org.springframework.boot.autoconfigure.web.ErrorController;
|
||||
@ -192,8 +192,8 @@ public class SpringBootWebSecurityConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@ConditionalOnExpression("!${security.basic.enabled:true}")
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "security.basic", name = "enabled", havingValue = "false")
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
protected static class ApplicationNoWebSecurityConfigurerAdapter extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
@ -208,8 +208,8 @@ public class SpringBootWebSecurityConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@ConditionalOnExpression("${security.basic.enabled:true}")
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "security.basic", name = "enabled", matchIfMissing = true)
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
protected static class ApplicationWebSecurityConfigurerAdapter extends
|
||||
WebSecurityConfigurerAdapter {
|
||||
|
@ -30,8 +30,8 @@ import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||
@ -97,7 +97,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnExpression("${error.whitelabel.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "error.whitelable", name = "enabled", matchIfMissing = true)
|
||||
@Conditional(ErrorTemplateMissingCondition.class)
|
||||
protected static class WhitelabelErrorViewConfiguration {
|
||||
|
||||
|
@ -22,8 +22,8 @@ import javax.servlet.Servlet;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
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.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -46,7 +46,7 @@ import org.springframework.web.multipart.support.StandardServletMultipartResolve
|
||||
@Configuration
|
||||
@ConditionalOnClass({ Servlet.class, StandardServletMultipartResolver.class,
|
||||
MultipartConfigElement.class })
|
||||
@ConditionalOnExpression("${multipart.enabled:true}")
|
||||
@ConditionalOnProperty(prefix = "multipart", name = "enabled", matchIfMissing = true)
|
||||
@EnableConfigurationProperties(MultipartProperties.class)
|
||||
public class MultipartAutoConfiguration {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user