|
|
@ -394,12 +394,14 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
protected static class DefaultConfiguration {
|
|
|
|
protected static class DefaultConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public TestProperties testProperties() {
|
|
|
|
public TestProperties testProperties() {
|
|
|
|
TestProperties test = new TestProperties();
|
|
|
|
TestProperties test = new TestProperties();
|
|
|
|
test.setName("bar");
|
|
|
|
test.setName("bar");
|
|
|
|
return test;
|
|
|
|
return test;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
@ -410,10 +412,12 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
@EnableConfigurationProperties
|
|
|
|
@EnableConfigurationProperties
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
public static class ExampleConfig {
|
|
|
|
public static class ExampleConfig {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public External external() {
|
|
|
|
public External external() {
|
|
|
|
return new External();
|
|
|
|
return new External();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@EnableConfigurationProperties(External.class)
|
|
|
|
@EnableConfigurationProperties(External.class)
|
|
|
@ -461,6 +465,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(name = "spring_test_external")
|
|
|
|
@ConfigurationProperties(name = "spring_test_external")
|
|
|
|
public static class SystemEnvVar {
|
|
|
|
public static class SystemEnvVar {
|
|
|
|
|
|
|
|
|
|
|
|
public String getVal() {
|
|
|
|
public String getVal() {
|
|
|
|
return this.val;
|
|
|
|
return this.val;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -475,6 +480,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
protected static class TestConsumer {
|
|
|
|
protected static class TestConsumer {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TestProperties properties;
|
|
|
|
private TestProperties properties;
|
|
|
|
|
|
|
|
|
|
|
@ -495,7 +501,9 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties
|
|
|
|
@ConfigurationProperties
|
|
|
|
protected static class NestedProperties {
|
|
|
|
protected static class NestedProperties {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
private Nested nested = new Nested();
|
|
|
|
private Nested nested = new Nested();
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
@ -507,6 +515,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected static class Nested {
|
|
|
|
protected static class Nested {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
@ -514,15 +523,18 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties
|
|
|
|
@ConfigurationProperties
|
|
|
|
protected static class BaseProperties {
|
|
|
|
protected static class BaseProperties {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected static class DerivedProperties extends BaseProperties {
|
|
|
|
protected static class DerivedProperties extends BaseProperties {
|
|
|
@ -530,8 +542,11 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties
|
|
|
|
@ConfigurationProperties
|
|
|
|
protected static class TestProperties {
|
|
|
|
protected static class TestProperties {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
private int[] array;
|
|
|
|
private int[] array;
|
|
|
|
|
|
|
|
|
|
|
|
private List<Integer> list = new ArrayList<Integer>();
|
|
|
|
private List<Integer> list = new ArrayList<Integer>();
|
|
|
|
|
|
|
|
|
|
|
|
// No getter - you should be able to bind to a write-only bean
|
|
|
|
// No getter - you should be able to bind to a write-only bean
|
|
|
@ -551,6 +566,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
public List<Integer> getList() {
|
|
|
|
public List<Integer> getList() {
|
|
|
|
return this.list;
|
|
|
|
return this.list;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(ignoreUnknownFields = false)
|
|
|
|
@ConfigurationProperties(ignoreUnknownFields = false)
|
|
|
@ -559,12 +575,10 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(name = "spring.foo")
|
|
|
|
@ConfigurationProperties(name = "spring.foo")
|
|
|
|
protected static class EmbeddedTestProperties extends TestProperties {
|
|
|
|
protected static class EmbeddedTestProperties extends TestProperties {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(ignoreUnknownFields = false, ignoreNestedProperties = true)
|
|
|
|
@ConfigurationProperties(ignoreUnknownFields = false, ignoreNestedProperties = true)
|
|
|
|
protected static class IgnoreNestedTestProperties extends TestProperties {
|
|
|
|
protected static class IgnoreNestedTestProperties extends TestProperties {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties
|
|
|
|
@ConfigurationProperties
|
|
|
@ -600,6 +614,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected static class MoreProperties {
|
|
|
|
protected static class MoreProperties {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
@ -611,6 +626,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
|
|
|
|
|
|
|
|
@ConfigurationProperties(path = "${binding.location:classpath:name.yml}")
|
|
|
|
@ConfigurationProperties(path = "${binding.location:classpath:name.yml}")
|
|
|
|
protected static class ResourceBindingProperties {
|
|
|
|
protected static class ResourceBindingProperties {
|
|
|
|
|
|
|
|
|
|
|
|
private String name;
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
|
|
|
|
public void setName(String name) {
|
|
|
|
public void setName(String name) {
|
|
|
@ -623,6 +639,7 @@ public class EnableConfigurationPropertiesTests {
|
|
|
|
@EnableConfigurationProperties
|
|
|
|
@EnableConfigurationProperties
|
|
|
|
@ConfigurationProperties(path = "${binding.location:classpath:map.yml}")
|
|
|
|
@ConfigurationProperties(path = "${binding.location:classpath:map.yml}")
|
|
|
|
protected static class ResourceBindingPropertiesWithMap {
|
|
|
|
protected static class ResourceBindingPropertiesWithMap {
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String> mymap;
|
|
|
|
private Map<String, String> mymap;
|
|
|
|
|
|
|
|
|
|
|
|
public void setMymap(Map<String, String> mymap) {
|
|
|
|
public void setMymap(Map<String, String> mymap) {
|
|
|
|