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
@@ -28,7 +28,7 @@ import org.springframework.util.MimeType;
|
||||
* @author Moritz Halbritter
|
||||
* @since 3.3.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "management.endpoint.sbom")
|
||||
@ConfigurationProperties("management.endpoint.sbom")
|
||||
public class SbomProperties {
|
||||
|
||||
/**
|
||||
|
||||
@@ -163,13 +163,13 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
|
||||
static class BaseConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo.primary")
|
||||
@ConfigurationProperties("foo.primary")
|
||||
Foo primaryFoo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo.secondary")
|
||||
@ConfigurationProperties("foo.secondary")
|
||||
Foo secondaryFoo() {
|
||||
return new Foo();
|
||||
}
|
||||
@@ -190,7 +190,7 @@ class ConfigurationPropertiesReportEndpointFilteringTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "only.bar")
|
||||
@ConfigurationProperties("only.bar")
|
||||
public static class Bar {
|
||||
|
||||
private String name = "123456";
|
||||
|
||||
@@ -89,13 +89,13 @@ class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "first")
|
||||
@ConfigurationProperties("first")
|
||||
Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "other")
|
||||
@ConfigurationProperties("other")
|
||||
Foo other() {
|
||||
return new Foo();
|
||||
}
|
||||
@@ -112,7 +112,7 @@ class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "other")
|
||||
@ConfigurationProperties("other")
|
||||
Bar bar() {
|
||||
return new Bar();
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class ConfigurationPropertiesReportEndpointMethodAnnotationsTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "test")
|
||||
@ConfigurationProperties("test")
|
||||
public static class Bar {
|
||||
|
||||
private String name = "654321";
|
||||
|
||||
@@ -111,7 +111,7 @@ class ConfigurationPropertiesReportEndpointParentTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "other")
|
||||
@ConfigurationProperties("other")
|
||||
OtherProperties otherProperties() {
|
||||
return new OtherProperties();
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class ConfigurationPropertiesReportEndpointParentTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "test")
|
||||
@ConfigurationProperties("test")
|
||||
static class TestProperties {
|
||||
|
||||
private String myTestProperty = "654321";
|
||||
|
||||
@@ -329,7 +329,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class FooConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
@@ -341,7 +341,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class SelfReferentialConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
SelfReferential foo() {
|
||||
return new SelfReferential();
|
||||
}
|
||||
@@ -353,7 +353,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class MetadataCycleConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "bar")
|
||||
@ConfigurationProperties("bar")
|
||||
SelfReferential foo() {
|
||||
return new SelfReferential();
|
||||
}
|
||||
@@ -365,7 +365,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class MapConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
MapHolder foo() {
|
||||
return new MapHolder();
|
||||
}
|
||||
@@ -377,7 +377,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class ListConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
ListHolder foo() {
|
||||
return new ListHolder();
|
||||
}
|
||||
@@ -389,7 +389,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class MetadataMapConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "spam")
|
||||
@ConfigurationProperties("spam")
|
||||
MapHolder foo() {
|
||||
return new MapHolder();
|
||||
}
|
||||
@@ -401,7 +401,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class AddressedConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
Addressed foo() {
|
||||
return new Addressed();
|
||||
}
|
||||
@@ -413,7 +413,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
static class InitializedMapAndListPropertiesConfig {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@ConfigurationProperties("foo")
|
||||
InitializedMapAndListProperties foo() {
|
||||
return new InitializedMapAndListProperties();
|
||||
}
|
||||
@@ -569,7 +569,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
|
||||
@Bean
|
||||
// gh-11037
|
||||
@ConfigurationProperties(prefix = "cycle")
|
||||
@ConfigurationProperties("cycle")
|
||||
Cycle cycle() {
|
||||
return new Cycle();
|
||||
}
|
||||
@@ -586,7 +586,7 @@ class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "test.datasource")
|
||||
@ConfigurationProperties("test.datasource")
|
||||
HikariDataSource hikariDataSource() {
|
||||
return new HikariDataSource();
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ class ConfigurationPropertiesReportEndpointTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "test")
|
||||
@ConfigurationProperties("test")
|
||||
public static class TestProperties {
|
||||
|
||||
private String dbPassword = "123456";
|
||||
@@ -524,7 +524,7 @@ class ConfigurationPropertiesReportEndpointTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "immutable")
|
||||
@ConfigurationProperties("immutable")
|
||||
public static class ImmutableProperties {
|
||||
|
||||
private final String dbPassword;
|
||||
@@ -574,7 +574,7 @@ class ConfigurationPropertiesReportEndpointTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "multiconstructor")
|
||||
@ConfigurationProperties("multiconstructor")
|
||||
public static class MultiConstructorProperties {
|
||||
|
||||
private final String name;
|
||||
@@ -613,7 +613,7 @@ class ConfigurationPropertiesReportEndpointTests {
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "autowired")
|
||||
@ConfigurationProperties("autowired")
|
||||
public static class AutowiredProperties {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -116,13 +116,13 @@ class ConfigurationPropertiesReportEndpointWebIntegrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "com.foo")
|
||||
@ConfigurationProperties("com.foo")
|
||||
Foo fooDotCom() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties(prefix = "com.bar")
|
||||
@ConfigurationProperties("com.bar")
|
||||
Bar barDotCom() {
|
||||
return new Bar();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@Validated
|
||||
@ConfigurationProperties(prefix = "validated")
|
||||
@ConfigurationProperties("validated")
|
||||
public class ValidatedConstructorBindingProperties {
|
||||
|
||||
private final String name;
|
||||
|
||||
Reference in New Issue
Block a user