Merge branch '2.7.x'
This commit is contained in:
@@ -148,8 +148,12 @@ public final class ConfigurationPropertiesBean {
|
||||
return getAll((ConfigurableApplicationContext) applicationContext);
|
||||
}
|
||||
Map<String, ConfigurationPropertiesBean> propertiesBeans = new LinkedHashMap<>();
|
||||
applicationContext.getBeansWithAnnotation(ConfigurationProperties.class)
|
||||
.forEach((beanName, bean) -> propertiesBeans.put(beanName, get(applicationContext, bean, beanName)));
|
||||
applicationContext.getBeansWithAnnotation(ConfigurationProperties.class).forEach((beanName, bean) -> {
|
||||
ConfigurationPropertiesBean propertiesBean = get(applicationContext, bean, beanName);
|
||||
if (propertiesBean != null) {
|
||||
propertiesBeans.put(beanName, propertiesBean);
|
||||
}
|
||||
});
|
||||
return propertiesBeans;
|
||||
}
|
||||
|
||||
@@ -163,7 +167,9 @@ public final class ConfigurationPropertiesBean {
|
||||
try {
|
||||
Object bean = beanFactory.getBean(beanName);
|
||||
ConfigurationPropertiesBean propertiesBean = get(applicationContext, bean, beanName);
|
||||
propertiesBeans.put(beanName, propertiesBean);
|
||||
if (propertiesBean != null) {
|
||||
propertiesBeans.put(beanName, propertiesBean);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
|
||||
@@ -78,6 +78,15 @@ class ConfigurationPropertiesBeanTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllDoesNotFindABeanDeclaredInAStaticBeanMethodOnAConfigurationAndConfigurationPropertiesAnnotatedClass() {
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
StaticBeanMethodConfiguration.class)) {
|
||||
Map<String, ConfigurationPropertiesBean> all = ConfigurationPropertiesBean.getAll(context);
|
||||
assertThat(all).containsOnlyKeys("configurationPropertiesBeanTests.StaticBeanMethodConfiguration");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAllWhenHasBadBeanDoesNotFail() {
|
||||
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
@@ -604,6 +613,18 @@ class ConfigurationPropertiesBeanTests {
|
||||
class ParameterizedConstructorInner {
|
||||
|
||||
ParameterizedConstructorInner(Integer age) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConfigurationProperties
|
||||
static class StaticBeanMethodConfiguration {
|
||||
|
||||
@Bean
|
||||
static String stringBean() {
|
||||
return "example";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user