From c10051022225fbcdbad7eba68a04fc7c03d65aeb Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 23 Mar 2018 11:20:32 +0900 Subject: [PATCH 1/2] Remove value in @ConditionalOnMissingBean if possible See gh-12604 --- .../autoconfigure/metrics/MetricsAutoConfiguration.java | 2 +- .../export/atlas/AtlasMetricsExportAutoConfiguration.java | 2 +- .../export/influx/InfluxMetricsExportAutoConfiguration.java | 2 +- .../export/simple/SimpleMetricsExportAutoConfiguration.java | 2 +- .../export/statsd/StatsdMetricsExportAutoConfiguration.java | 2 +- .../wavefront/WavefrontMetricsExportAutoConfiguration.java | 2 +- .../metrics/web/tomcat/TomcatMetricsAutoConfiguration.java | 2 +- .../boot/autoconfigure/amqp/RabbitAutoConfiguration.java | 4 ++-- .../PersistenceExceptionTranslationAutoConfiguration.java | 2 +- .../cassandra/CassandraReactiveDataAutoConfiguration.java | 2 +- .../autoconfigure/data/redis/RedisAutoConfiguration.java | 2 +- .../boot/autoconfigure/gson/GsonAutoConfiguration.java | 4 ++-- .../autoconfigure/jackson/JacksonAutoConfiguration.java | 6 +++--- .../boot/autoconfigure/jmx/JmxAutoConfiguration.java | 2 +- .../boot/autoconfigure/jooq/JooqAutoConfiguration.java | 2 +- .../boot/autoconfigure/kafka/KafkaAutoConfiguration.java | 2 +- .../autoconfigure/mustache/MustacheAutoConfiguration.java | 2 +- .../mustache/MustacheReactiveWebConfiguration.java | 2 +- .../mustache/MustacheServletWebConfiguration.java | 2 +- .../boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java | 2 +- .../autoconfigure/security/SecurityDataConfiguration.java | 2 +- .../autoconfigure/sendgrid/SendGridAutoConfiguration.java | 2 +- .../autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java | 2 +- .../transaction/jta/NarayanaJtaConfiguration.java | 2 +- .../web/servlet/HttpEncodingAutoConfiguration.java | 2 +- .../web/servlet/error/ErrorMvcAutoConfiguration.java | 2 +- .../autoconfigure/restdocs/RestDocsAutoConfiguration.java | 6 +++--- 27 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java index 731b172e68..6ee92c6779 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java @@ -115,7 +115,7 @@ public class MetricsAutoConfiguration { @ConditionalOnClass(name = { "ch.qos.logback.classic.LoggerContext", "org.slf4j.LoggerFactory" }) @Conditional(LogbackLoggingCondition.class) - @ConditionalOnMissingBean(LogbackMetrics.class) + @ConditionalOnMissingBean @ConditionalOnProperty(value = "management.metrics.binders.logback.enabled", matchIfMissing = true) public LogbackMetrics logbackMetrics() { return new LogbackMetrics(); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.java index 7b3e8a6ed6..077ae67f31 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.java @@ -52,7 +52,7 @@ import org.springframework.context.annotation.Configuration; public class AtlasMetricsExportAutoConfiguration { @Bean - @ConditionalOnMissingBean(AtlasConfig.class) + @ConditionalOnMissingBean public AtlasConfig atlasConfig(AtlasProperties atlasProperties) { return new AtlasPropertiesConfigAdapter(atlasProperties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java index fe5a3905de..fda2346931 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java @@ -51,7 +51,7 @@ import org.springframework.context.annotation.Configuration; public class InfluxMetricsExportAutoConfiguration { @Bean - @ConditionalOnMissingBean(InfluxConfig.class) + @ConditionalOnMissingBean public InfluxConfig influxConfig(InfluxProperties influxProperties) { return new InfluxPropertiesConfigAdapter(influxProperties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java index f2dbde05a2..29a3454a6a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java @@ -56,7 +56,7 @@ public class SimpleMetricsExportAutoConfiguration { } @Bean - @ConditionalOnMissingBean(SimpleConfig.class) + @ConditionalOnMissingBean public SimpleConfig simpleConfig(SimpleProperties simpleProperties) { return new SimplePropertiesConfigAdapter(simpleProperties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.java index 0eeff49a10..fdfa8c1c3d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.java @@ -53,7 +53,7 @@ import org.springframework.context.annotation.Configuration; public class StatsdMetricsExportAutoConfiguration { @Bean - @ConditionalOnMissingBean(StatsdConfig.class) + @ConditionalOnMissingBean public StatsdConfig statsdConfig(StatsdProperties statsdProperties) { return new StatsdPropertiesConfigAdapter(statsdProperties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java index c8dfe66461..1e3062e851 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java @@ -51,7 +51,7 @@ import org.springframework.context.annotation.Configuration; public class WavefrontMetricsExportAutoConfiguration { @Bean - @ConditionalOnMissingBean(WavefrontConfig.class) + @ConditionalOnMissingBean public WavefrontConfig wavefrontConfig(WavefrontProperties props) { return new WavefrontPropertiesConfigAdapter(props); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java index 3053e2ca97..59c842bfe3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java @@ -45,7 +45,7 @@ public class TomcatMetricsAutoConfiguration { private volatile Context context; @Bean - @ConditionalOnMissingBean(TomcatMetrics.class) + @ConditionalOnMissingBean public TomcatMetrics tomcatMetrics() { return new TomcatMetrics(this.context == null ? null : this.context.getManager(), Collections.emptyList()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index c0ff9b1ea5..d08d1b2c76 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -167,7 +167,7 @@ public class RabbitAutoConfiguration { @Bean @ConditionalOnSingleCandidate(ConnectionFactory.class) - @ConditionalOnMissingBean(RabbitTemplate.class) + @ConditionalOnMissingBean public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { PropertyMapper map = PropertyMapper.get(); RabbitTemplate template = new RabbitTemplate(connectionFactory); @@ -213,7 +213,7 @@ public class RabbitAutoConfiguration { @Bean @ConditionalOnSingleCandidate(ConnectionFactory.class) @ConditionalOnProperty(prefix = "spring.rabbitmq", name = "dynamic", matchIfMissing = true) - @ConditionalOnMissingBean(AmqpAdmin.class) + @ConditionalOnMissingBean public AmqpAdmin amqpAdmin(ConnectionFactory connectionFactory) { return new RabbitAdmin(connectionFactory); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java index 3810e8a6f7..48da026096 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java @@ -37,7 +37,7 @@ import org.springframework.dao.annotation.PersistenceExceptionTranslationPostPro public class PersistenceExceptionTranslationAutoConfiguration { @Bean - @ConditionalOnMissingBean(PersistenceExceptionTranslationPostProcessor.class) + @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "spring.dao.exceptiontranslation", name = "enabled", matchIfMissing = true) public static PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor( Environment environment) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java index 1df76b81f7..cc424c66a7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java @@ -49,7 +49,7 @@ import org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessio public class CassandraReactiveDataAutoConfiguration { @Bean - @ConditionalOnMissingBean(ReactiveSession.class) + @ConditionalOnMissingBean public ReactiveSession reactiveCassandraSession(Session session) { return new DefaultBridgedReactiveSession(session); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java index 2c9a369853..c6c423022d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java @@ -59,7 +59,7 @@ public class RedisAutoConfiguration { } @Bean - @ConditionalOnMissingBean(StringRedisTemplate.class) + @ConditionalOnMissingBean public StringRedisTemplate stringRedisTemplate( RedisConnectionFactory redisConnectionFactory) throws UnknownHostException { StringRedisTemplate template = new StringRedisTemplate(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java index 97aced8a0f..6956a5da71 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java @@ -43,7 +43,7 @@ import org.springframework.core.Ordered; public class GsonAutoConfiguration { @Bean - @ConditionalOnMissingBean(GsonBuilder.class) + @ConditionalOnMissingBean public GsonBuilder gsonBuilder(List customizers) { GsonBuilder builder = new GsonBuilder(); customizers.forEach((c) -> c.customize(builder)); @@ -51,7 +51,7 @@ public class GsonAutoConfiguration { } @Bean - @ConditionalOnMissingBean(Gson.class) + @ConditionalOnMissingBean public Gson gson(GsonBuilder gsonBuilder) { return gsonBuilder.create(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java index 5280a4b6dc..89fb576f3b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java @@ -98,7 +98,7 @@ public class JacksonAutoConfiguration { @Bean @Primary - @ConditionalOnMissingBean(ObjectMapper.class) + @ConditionalOnMissingBean public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { return builder.createXmlMapper(false).build(); } @@ -161,7 +161,7 @@ public class JacksonAutoConfiguration { static class ParameterNamesModuleConfiguration { @Bean - @ConditionalOnMissingBean(ParameterNamesModule.class) + @ConditionalOnMissingBean public ParameterNamesModule parameterNamesModule() { return new ParameterNamesModule(JsonCreator.Mode.DEFAULT); } @@ -179,7 +179,7 @@ public class JacksonAutoConfiguration { } @Bean - @ConditionalOnMissingBean(Jackson2ObjectMapperBuilder.class) + @ConditionalOnMissingBean public Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder( List customizers) { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java index 9b7f18e9e0..2f0e7cdf68 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java @@ -97,7 +97,7 @@ public class JmxAutoConfiguration implements EnvironmentAware, BeanFactoryAware } @Bean - @ConditionalOnMissingBean(MBeanServer.class) + @ConditionalOnMissingBean public MBeanServer mbeanServer() { SpecificPlatform platform = SpecificPlatform.get(); if (platform != null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java index 567da2de10..8c84c537c7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java @@ -60,7 +60,7 @@ import org.springframework.transaction.PlatformTransactionManager; public class JooqAutoConfiguration { @Bean - @ConditionalOnMissingBean(DataSourceConnectionProvider.class) + @ConditionalOnMissingBean public DataSourceConnectionProvider dataSourceConnectionProvider( DataSource dataSource) { return new DataSourceConnectionProvider( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java index cf6c4dd34c..abfe5d9a49 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java @@ -131,7 +131,7 @@ public class KafkaAutoConfiguration { } @Bean - @ConditionalOnMissingBean(KafkaAdmin.class) + @ConditionalOnMissingBean public KafkaAdmin kafkaAdmin() { KafkaAdmin kafkaAdmin = new KafkaAdmin(this.properties.buildAdminProperties()); kafkaAdmin.setFatalIfBrokerNotAvailable(this.properties.getAdmin().isFailFast()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java index 90cffe0354..ab8bae55a9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java @@ -77,7 +77,7 @@ public class MustacheAutoConfiguration { } @Bean - @ConditionalOnMissingBean(Mustache.Compiler.class) + @ConditionalOnMissingBean public Mustache.Compiler mustacheCompiler(TemplateLoader mustacheTemplateLoader) { return Mustache.compiler().withLoader(mustacheTemplateLoader) .withCollector(collector()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java index 55502245f0..5ca68cfdbe 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java @@ -37,7 +37,7 @@ class MustacheReactiveWebConfiguration { } @Bean - @ConditionalOnMissingBean(MustacheViewResolver.class) + @ConditionalOnMissingBean public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) { MustacheViewResolver resolver = new MustacheViewResolver(mustacheCompiler); resolver.setPrefix(this.mustache.getPrefix()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java index 2f0dae85da..92fcb19958 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java @@ -37,7 +37,7 @@ class MustacheServletWebConfiguration { } @Bean - @ConditionalOnMissingBean(MustacheViewResolver.class) + @ConditionalOnMissingBean public MustacheViewResolver mustacheViewResolver(Compiler mustacheCompiler) { MustacheViewResolver resolver = new MustacheViewResolver(mustacheCompiler); this.mustache.applyToMvcViewResolver(resolver); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java index 40e64d931d..0c64dbe30f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java @@ -94,7 +94,7 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware { } @Bean - @ConditionalOnMissingBean(PlatformTransactionManager.class) + @ConditionalOnMissingBean public PlatformTransactionManager transactionManager() { JpaTransactionManager transactionManager = new JpaTransactionManager(); if (this.transactionManagerCustomizers != null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java index 5f18cd4d7d..8190821176 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java @@ -34,7 +34,7 @@ import org.springframework.security.data.repository.query.SecurityEvaluationCont EvaluationContextExtensionSupport.class }) public class SecurityDataConfiguration { - @ConditionalOnMissingBean(SecurityEvaluationContextExtension.class) + @ConditionalOnMissingBean @Bean public SecurityEvaluationContextExtension securityEvaluationContextExtension() { return new SecurityEvaluationContextExtension(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java index 5a0aee120f..ad084559a8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java @@ -50,7 +50,7 @@ public class SendGridAutoConfiguration { } @Bean - @ConditionalOnMissingBean(SendGrid.class) + @ConditionalOnMissingBean public SendGrid sendGrid() { if (this.properties.isProxyConfigured()) { HttpHost proxy = new HttpHost(this.properties.getProxy().getHost(), diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index e273c04d45..a1c1c7d3d0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -147,7 +147,7 @@ public class ThymeleafAutoConfiguration { } @Bean - @ConditionalOnMissingBean(SpringTemplateEngine.class) + @ConditionalOnMissingBean public SpringTemplateEngine templateEngine() { SpringTemplateEngine engine = new SpringTemplateEngine(); engine.setEnableSpringELCompiler(this.properties.isEnableSpringElCompiler()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java index 83f166abc3..bec12cfc62 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java @@ -139,7 +139,7 @@ public class NarayanaJtaConfiguration { } @Bean - @ConditionalOnMissingBean(XADataSourceWrapper.class) + @ConditionalOnMissingBean public XADataSourceWrapper xaDataSourceWrapper( NarayanaRecoveryManagerBean narayanaRecoveryManagerBean, NarayanaProperties narayanaProperties) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java index b5519e7d87..b24d4473b6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java @@ -54,7 +54,7 @@ public class HttpEncodingAutoConfiguration { } @Bean - @ConditionalOnMissingBean(CharacterEncodingFilter.class) + @ConditionalOnMissingBean public CharacterEncodingFilter characterEncodingFilter() { CharacterEncodingFilter filter = new OrderedCharacterEncodingFilter(); filter.setEncoding(this.properties.getCharset().name()); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java index 5cc2a40009..5c16f7f9db 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java @@ -170,7 +170,7 @@ public class ErrorMvcAutoConfiguration { // If the user adds @EnableWebMvc then the bean name view resolver from // WebMvcAutoConfiguration disappears, so add it back in to avoid disappointment. @Bean - @ConditionalOnMissingBean(BeanNameViewResolver.class) + @ConditionalOnMissingBean public BeanNameViewResolver beanNameViewResolver() { BeanNameViewResolver resolver = new BeanNameViewResolver(); resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java index 4f18dbc652..aece769a6b 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/restdocs/RestDocsAutoConfiguration.java @@ -56,7 +56,7 @@ public class RestDocsAutoConfiguration { static class RestDocsMockMvcAutoConfiguration { @Bean - @ConditionalOnMissingBean(MockMvcRestDocumentationConfigurer.class) + @ConditionalOnMissingBean public MockMvcRestDocumentationConfigurer restDocsMockMvcConfigurer( ObjectProvider configurationCustomizerProvider, RestDocumentationContextProvider contextProvider) { @@ -88,7 +88,7 @@ public class RestDocsAutoConfiguration { static class RestDocsRestAssuredAutoConfiguration { @Bean - @ConditionalOnMissingBean(RequestSpecification.class) + @ConditionalOnMissingBean public RequestSpecification restDocsRestAssuredConfigurer( ObjectProvider configurationCustomizerProvider, RestDocumentationContextProvider contextProvider) { @@ -117,7 +117,7 @@ public class RestDocsAutoConfiguration { static class RestDocsWebTestClientAutoConfiguration { @Bean - @ConditionalOnMissingBean(WebTestClientRestDocumentationConfigurer.class) + @ConditionalOnMissingBean public WebTestClientRestDocumentationConfigurer restDocsWebTestClientConfigurer( ObjectProvider configurationCustomizerProvider, RestDocumentationContextProvider contextProvider) { From 62cc4e955253837c796d23b424bab5e5fd835697 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 26 Mar 2018 17:39:07 +0200 Subject: [PATCH 2/2] Polish "Remove value in @ConditionalOnMissingBean if possible" Closes gh-12604 --- .../dao/PersistenceExceptionTranslationAutoConfiguration.java | 2 +- .../cassandra/CassandraReactiveDataAutoConfiguration.java | 2 +- .../boot/autoconfigure/jmx/JmxAutoConfiguration.java | 2 +- .../boot/autoconfigure/jooq/JooqAutoConfiguration.java | 2 +- .../boot/autoconfigure/kafka/KafkaAutoConfiguration.java | 2 +- .../autoconfigure/mustache/MustacheAutoConfiguration.java | 2 +- .../mustache/MustacheReactiveWebConfiguration.java | 2 +- .../mustache/MustacheServletWebConfiguration.java | 2 +- .../autoconfigure/security/SecurityDataConfiguration.java | 4 ++-- .../autoconfigure/sendgrid/SendGridAutoConfiguration.java | 2 +- .../autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java index 48da026096..bc5a1e2be6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java index cc424c66a7..bf279901f1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java index 2f0e7cdf68..7c68d99d5d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java index 8c84c537c7..870ffa4621 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java index abfe5d9a49..0bc7e88e2c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java index ab8bae55a9..0530bcaa01 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java index 5ca68cfdbe..b814f31eb3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheReactiveWebConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java index 92fcb19958..b6ff696a40 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheServletWebConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java index 8190821176..dee1f62aa3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityDataConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. @@ -34,8 +34,8 @@ import org.springframework.security.data.repository.query.SecurityEvaluationCont EvaluationContextExtensionSupport.class }) public class SecurityDataConfiguration { - @ConditionalOnMissingBean @Bean + @ConditionalOnMissingBean public SecurityEvaluationContextExtension securityEvaluationContextExtension() { return new SecurityEvaluationContextExtension(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java index ad084559a8..288cef4439 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java index a1c1c7d3d0..97c9d783a6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 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.