Refine ignored @PropertySource log warning
If the enclosing environment does not implement ConfigurableEnvironment, then @PropertySource annotations are ignored because there is no way to add them to the Environment. Now checking first to see if there are any @PropertySource annotations present before issuing the warning. Issue: SPR-8314 git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4295 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
6d06f137cf
commit
2b0b4a58cb
|
|
@ -247,15 +247,17 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
parser.validate();
|
parser.validate();
|
||||||
|
|
||||||
// Handle any @PropertySource annotations
|
// Handle any @PropertySource annotations
|
||||||
if (!(this.environment instanceof ConfigurableEnvironment)) {
|
Stack<PropertySource<?>> parsedPropertySources = parser.getPropertySources();
|
||||||
logger.warn("Ignoring @PropertySource annotations. " +
|
if (!parsedPropertySources.isEmpty()) {
|
||||||
"Reason: Environment must implement ConfigurableEnvironment");
|
if (!(this.environment instanceof ConfigurableEnvironment)) {
|
||||||
}
|
logger.warn("Ignoring @PropertySource annotations. " +
|
||||||
else {
|
"Reason: Environment must implement ConfigurableEnvironment");
|
||||||
MutablePropertySources envPropertySources = ((ConfigurableEnvironment)this.environment).getPropertySources();
|
}
|
||||||
Stack<PropertySource<?>> parsedPropertySources = parser.getPropertySources();
|
else {
|
||||||
while (!parsedPropertySources.isEmpty()) {
|
MutablePropertySources envPropertySources = ((ConfigurableEnvironment)this.environment).getPropertySources();
|
||||||
envPropertySources.addLast(parsedPropertySources.pop());
|
while (!parsedPropertySources.isEmpty()) {
|
||||||
|
envPropertySources.addLast(parsedPropertySources.pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue