Refactor @ConfigurationProperties that only use prefix
See gh-43917 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
committed by
Phillip Webb
parent
7bcdb7d3ee
commit
c1d97ffe16
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.messaging")
|
||||
@ConfigurationProperties("my.messaging")
|
||||
public class MyMessagingProperties {
|
||||
|
||||
private List<String> addresses = new ArrayList<>(Arrays.asList("a", "b"));
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.appendix.configurationmetadata.annotationp
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
@ConfigurationProperties("my.server")
|
||||
public class MyServerProperties {
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.appendix.configurationmetadata.annotationp
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
@ConfigurationProperties("my.server")
|
||||
public class MyServerProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.main-project.person")
|
||||
@ConfigurationProperties("my.main-project.person")
|
||||
public class MyPersonProperties {
|
||||
|
||||
private String firstName;
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.props")
|
||||
@ConfigurationProperties("my.props")
|
||||
public class MyMapsProperties {
|
||||
|
||||
private final Map<String, String> values = new HashMap<>();
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class ThirdPartyConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "another")
|
||||
@ConfigurationProperties("another")
|
||||
public AnotherComponent anotherComponent() {
|
||||
return new AnotherComponent();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class MyDataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "app.datasource")
|
||||
@ConfigurationProperties("app.datasource")
|
||||
public SomeDataSource dataSource() {
|
||||
return new SomeDataSource();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.packaging.nativeimage.advanced.nestedconfi
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.properties")
|
||||
@ConfigurationProperties("my.properties")
|
||||
public class MyProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.packaging.nativeimage.advanced.nestedconfi
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.properties")
|
||||
@ConfigurationProperties("my.properties")
|
||||
public class MyPropertiesCtor {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.packaging.nativeimage.advanced.nestedconfi
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties(prefix = "my.properties")
|
||||
@ConfigurationProperties("my.properties")
|
||||
public record MyPropertiesRecord(String name, @NestedConfigurationProperty Nested nested) {
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import java.util.Arrays
|
||||
|
||||
@ConfigurationProperties(prefix = "my.messaging")
|
||||
@ConfigurationProperties("my.messaging")
|
||||
class MyMessagingProperties(
|
||||
|
||||
val addresses: List<String> = ArrayList(Arrays.asList("a", "b")),
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
@ConfigurationProperties("my.server")
|
||||
class MyServerProperties(
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
@ConfigurationProperties("my.server")
|
||||
class MyServerProperties(
|
||||
var name: String,
|
||||
var host: Host) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties(prefix = "my.main-project.person")
|
||||
@ConfigurationProperties("my.main-project.person")
|
||||
class MyPersonProperties {
|
||||
|
||||
var firstName: String? = null
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
|
||||
@ConfigurationProperties(prefix = "my.props")
|
||||
@ConfigurationProperties("my.props")
|
||||
class MyMapsProperties {
|
||||
|
||||
val values: Map<String, String> = HashMap()
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration
|
||||
class ThirdPartyConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "another")
|
||||
@ConfigurationProperties("another")
|
||||
fun anotherComponent(): AnotherComponent = AnotherComponent()
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration
|
||||
class MyDataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "app.datasource")
|
||||
@ConfigurationProperties("app.datasource")
|
||||
fun dataSource(): SomeDataSource {
|
||||
return SomeDataSource()
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.boot.docs.packaging.nativeimage.advanced.nestedconfi
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty
|
||||
|
||||
@ConfigurationProperties(prefix = "my.properties")
|
||||
@ConfigurationProperties("my.properties")
|
||||
data class MyPropertiesKotlin(
|
||||
val name: String,
|
||||
@NestedConfigurationProperty val nested: Nested
|
||||
|
||||
Reference in New Issue
Block a user