AbstractApplicationContext registers default embedded value resolver
Issue: SPR-14140
This commit is contained in:
@@ -78,6 +78,7 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
/**
|
||||
* Abstract implementation of the {@link org.springframework.context.ApplicationContext}
|
||||
@@ -825,6 +826,18 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
beanFactory.getBean(CONVERSION_SERVICE_BEAN_NAME, ConversionService.class));
|
||||
}
|
||||
|
||||
// Register a default embedded value resolver if no bean post-processor
|
||||
// (such as a PropertyPlaceholderConfigurer bean) registered any before:
|
||||
// at this point, primarily for resolution in annotation attribute values.
|
||||
if (!beanFactory.hasEmbeddedValueResolver()) {
|
||||
beanFactory.addEmbeddedValueResolver(new StringValueResolver() {
|
||||
@Override
|
||||
public String resolveStringValue(String strVal) {
|
||||
return getEnvironment().resolvePlaceholders(strVal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
|
||||
String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
|
||||
for (String weaverAwareName : weaverAwareNames) {
|
||||
|
||||
Reference in New Issue
Block a user