Skip to content

Commit 4c307d6

Browse files
committed
Switch away from using @ConditionalOnProperty prefix
Merge `prefix` into `name` attribute and simplify annotations where possible. Closes gh-43703
1 parent 29e9ce1 commit 4c307d6

File tree

48 files changed

+101
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+101
-112
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/otlp/OtlpLoggingConfigurations.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static class ConnectionDetails {
4646

4747
@Bean
4848
@ConditionalOnMissingBean
49-
@ConditionalOnProperty(prefix = "management.otlp.logging", name = "endpoint")
49+
@ConditionalOnProperty("management.otlp.logging.endpoint")
5050
OtlpLoggingConnectionDetails otlpLoggingConnectionDetails(OtlpLoggingProperties properties) {
5151
return new PropertiesOtlpLoggingConnectionDetails(properties);
5252
}
@@ -81,8 +81,7 @@ public String getUrl(Transport transport) {
8181
static class Exporters {
8282

8383
@Bean
84-
@ConditionalOnProperty(prefix = "management.otlp.logging", name = "transport", havingValue = "http",
85-
matchIfMissing = true)
84+
@ConditionalOnProperty(name = "management.otlp.logging.transport", havingValue = "http", matchIfMissing = true)
8685
OtlpHttpLogRecordExporter otlpHttpLogRecordExporter(OtlpLoggingProperties properties,
8786
OtlpLoggingConnectionDetails connectionDetails) {
8887
OtlpHttpLogRecordExporterBuilder builder = OtlpHttpLogRecordExporter.builder()
@@ -95,7 +94,7 @@ OtlpHttpLogRecordExporter otlpHttpLogRecordExporter(OtlpLoggingProperties proper
9594
}
9695

9796
@Bean
98-
@ConditionalOnProperty(prefix = "management.otlp.logging", name = "transport", havingValue = "grpc")
97+
@ConditionalOnProperty(name = "management.otlp.logging.transport", havingValue = "grpc")
9998
OtlpGrpcLogRecordExporter otlpGrpcLogRecordExporter(OtlpLoggingProperties properties,
10099
OtlpLoggingConnectionDetails connectionDetails) {
101100
OtlpGrpcLogRecordExporterBuilder builder = OtlpGrpcLogRecordExporter.builder()

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/otlp/OtlpTracingConfigurations.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static class ConnectionDetails {
4444

4545
@Bean
4646
@ConditionalOnMissingBean
47-
@ConditionalOnProperty(prefix = "management.otlp.tracing", name = "endpoint")
47+
@ConditionalOnProperty("management.otlp.tracing.endpoint")
4848
OtlpTracingConnectionDetails otlpTracingConnectionDetails(OtlpTracingProperties properties) {
4949
return new PropertiesOtlpTracingConnectionDetails(properties);
5050
}
@@ -79,8 +79,7 @@ public String getUrl(Transport transport) {
7979
static class Exporters {
8080

8181
@Bean
82-
@ConditionalOnProperty(prefix = "management.otlp.tracing", name = "transport", havingValue = "http",
83-
matchIfMissing = true)
82+
@ConditionalOnProperty(name = "management.otlp.tracing.transport", havingValue = "http", matchIfMissing = true)
8483
OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpTracingProperties properties,
8584
OtlpTracingConnectionDetails connectionDetails) {
8685
OtlpHttpSpanExporterBuilder builder = OtlpHttpSpanExporter.builder()
@@ -93,7 +92,7 @@ OtlpHttpSpanExporter otlpHttpSpanExporter(OtlpTracingProperties properties,
9392
}
9493

9594
@Bean
96-
@ConditionalOnProperty(prefix = "management.otlp.tracing", name = "transport", havingValue = "grpc")
95+
@ConditionalOnProperty(name = "management.otlp.tracing.transport", havingValue = "grpc")
9796
OtlpGrpcSpanExporter otlpGrpcSpanExporter(OtlpTracingProperties properties,
9897
OtlpTracingConnectionDetails connectionDetails) {
9998
OtlpGrpcSpanExporterBuilder builder = OtlpGrpcSpanExporter.builder()

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ public ManagementServletContext managementServletContext(WebEndpointProperties p
6060
// Put Servlets and Filters in their own nested class so they don't force early
6161
// instantiation of ManagementServerProperties.
6262
@Configuration(proxyBeanMethods = false)
63-
@ConditionalOnProperty(prefix = "management.server", name = "add-application-context-header", havingValue = "true")
63+
@ConditionalOnProperty(name = "management.server.add-application-context-header", havingValue = "true")
6464
protected static class ApplicationContextFilterConfiguration {
6565

6666
@Bean

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAnnotationDrivenConfiguration.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ SimpleRabbitListenerContainerFactoryConfigurer simpleRabbitListenerContainerFact
8282

8383
@Bean(name = "rabbitListenerContainerFactory")
8484
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
85-
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "simple",
86-
matchIfMissing = true)
85+
@ConditionalOnProperty(name = "spring.rabbitmq.listener.type", havingValue = "simple", matchIfMissing = true)
8786
SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory(
8887
SimpleRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory,
8988
ObjectProvider<ContainerCustomizer<SimpleMessageListenerContainer>> simpleContainerCustomizer) {
@@ -111,7 +110,7 @@ DirectRabbitListenerContainerFactoryConfigurer directRabbitListenerContainerFact
111110

112111
@Bean(name = "rabbitListenerContainerFactory")
113112
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
114-
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "direct")
113+
@ConditionalOnProperty(name = "spring.rabbitmq.listener.type", havingValue = "direct")
115114
DirectRabbitListenerContainerFactory directRabbitListenerContainerFactory(
116115
DirectRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory,
117116
ObjectProvider<ContainerCustomizer<DirectMessageListenerContainer>> directContainerCustomizer) {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public RabbitTemplate rabbitTemplate(RabbitTemplateConfigurer configurer, Connec
164164

165165
@Bean
166166
@ConditionalOnSingleCandidate(ConnectionFactory.class)
167-
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "dynamic", matchIfMissing = true)
167+
@ConditionalOnProperty(name = "spring.rabbitmq.dynamic", matchIfMissing = true)
168168
@ConditionalOnMissingBean
169169
public AmqpAdmin amqpAdmin(ConnectionFactory connectionFactory) {
170170
return new RabbitAdmin(connectionFactory);

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitStreamConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class RabbitStreamConfiguration {
5252

5353
@Bean(name = "rabbitListenerContainerFactory")
5454
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
55-
@ConditionalOnProperty(prefix = "spring.rabbitmq.listener", name = "type", havingValue = "stream")
55+
@ConditionalOnProperty(name = "spring.rabbitmq.listener.type", havingValue = "stream")
5656
StreamRabbitListenerContainerFactory streamRabbitListenerContainerFactory(Environment rabbitStreamEnvironment,
5757
RabbitProperties properties, ObjectProvider<ConsumerCustomizer> consumerCustomizer,
5858
ObjectProvider<ContainerCustomizer<StreamListenerContainer>> containerCustomizer) {
@@ -90,7 +90,7 @@ RabbitStreamTemplateConfigurer rabbitStreamTemplateConfigurer(RabbitProperties p
9090

9191
@Bean
9292
@ConditionalOnMissingBean(RabbitStreamOperations.class)
93-
@ConditionalOnProperty(prefix = "spring.rabbitmq.stream", name = "name")
93+
@ConditionalOnProperty(name = "spring.rabbitmq.stream.name")
9494
RabbitStreamTemplate rabbitStreamTemplate(Environment rabbitStreamEnvironment, RabbitProperties properties,
9595
RabbitStreamTemplateConfigurer configurer) {
9696
RabbitStreamTemplate template = new RabbitStreamTemplate(rabbitStreamEnvironment,

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
4444
* @see EnableAspectJAutoProxy
4545
*/
4646
@AutoConfiguration
47-
@ConditionalOnProperty(prefix = "spring.aop", name = "auto", havingValue = "true", matchIfMissing = true)
47+
@ConditionalOnProperty(name = "spring.aop.auto", havingValue = "true", matchIfMissing = true)
4848
public class AopAutoConfiguration {
4949

5050
@Configuration(proxyBeanMethods = false)
@@ -53,15 +53,14 @@ static class AspectJAutoProxyingConfiguration {
5353

5454
@Configuration(proxyBeanMethods = false)
5555
@EnableAspectJAutoProxy(proxyTargetClass = false)
56-
@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "false")
56+
@ConditionalOnProperty(name = "spring.aop.proxy-target-class", havingValue = "false")
5757
static class JdkDynamicAutoProxyConfiguration {
5858

5959
}
6060

6161
@Configuration(proxyBeanMethods = false)
6262
@EnableAspectJAutoProxy(proxyTargetClass = true)
63-
@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "true",
64-
matchIfMissing = true)
63+
@ConditionalOnProperty(name = "spring.aop.proxy-target-class", havingValue = "true", matchIfMissing = true)
6564
static class CglibAutoProxyConfiguration {
6665

6766
}
@@ -70,8 +69,7 @@ static class CglibAutoProxyConfiguration {
7069

7170
@Configuration(proxyBeanMethods = false)
7271
@ConditionalOnMissingClass("org.aspectj.weaver.Advice")
73-
@ConditionalOnProperty(prefix = "spring.aop", name = "proxy-target-class", havingValue = "true",
74-
matchIfMissing = true)
72+
@ConditionalOnProperty(name = "spring.aop.proxy-target-class", havingValue = "true", matchIfMissing = true)
7573
static class ClassProxyingConfiguration {
7674

7775
@Bean

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static final class CouchbaseCondition extends AnyNestedCondition {
228228
super(ConfigurationPhase.REGISTER_BEAN);
229229
}
230230

231-
@ConditionalOnProperty(prefix = "spring.couchbase", name = "connection-string")
231+
@ConditionalOnProperty("spring.couchbase.connection-string")
232232
private static final class CouchbaseUrlCondition {
233233

234234
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@ private static final class BootstrapExecutorCondition extends AnyNestedCondition
104104
super(ConfigurationPhase.REGISTER_BEAN);
105105
}
106106

107-
@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "bootstrap-mode",
108-
havingValue = "deferred")
107+
@ConditionalOnProperty(name = "spring.data.jpa.repositories.bootstrap-mode", havingValue = "deferred")
109108
static class DeferredBootstrapMode {
110109

111110
}
112111

113-
@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "bootstrap-mode", havingValue = "lazy")
112+
@ConditionalOnProperty(name = "spring.data.jpa.repositories.bootstrap-mode", havingValue = "lazy")
114113
static class LazyBootstrapMode {
115114

116115
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private static final class JdbcConnectionDetailsCondition {
450450

451451
}
452452

453-
@ConditionalOnProperty(prefix = "spring.flyway", name = "url")
453+
@ConditionalOnProperty("spring.flyway.url")
454454
private static final class FlywayUrlCondition {
455455

456456
}

0 commit comments

Comments
 (0)