Class PropertySourcesPlaceholderConfigurer
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- BeanFactoryPostProcessor,- EnvironmentAware,- Ordered,- PriorityOrdered
PlaceholderConfigurerSupport that resolves ${...} placeholders
 within bean definition property values and @Value annotations against the current
 Spring Environment and its set of PropertySources.
 This class is designed as a general replacement for PropertyPlaceholderConfigurer.
 It is used by default to support the property-placeholder element in working against
 the spring-context-3.1 or higher XSD; whereas, spring-context versions <= 3.0 default to
 PropertyPlaceholderConfigurer to ensure backward compatibility. See the spring-context
 XSD documentation for complete details.
 
Any local properties (for example, those added via PropertiesLoaderSupport.setProperties(java.util.Properties), PropertiesLoaderSupport.setLocations(org.springframework.core.io.Resource...)
 et al.) are added as a single PropertySource. Search precedence of local properties is
 based on the value of the localOverride property, which is by
 default false meaning that local properties are to be searched last, after all
 environment property sources.
 
See ConfigurableEnvironment and related javadocs
 for details on manipulating environment property sources.
- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller, Sam Brannen
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final String"environmentProperties" is the name given to thePropertySourcethat wraps the environment supplied to this configurer.static final String"localProperties" is the name given to thePropertySourcefor the set of merged properties supplied to this configurer.Fields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupportDEFAULT_ESCAPE_CHARACTER, DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, escapeCharacter, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, trimValues, valueSeparatorFields inherited from class org.springframework.core.io.support.PropertiesLoaderSupportlocalOverride, localProperties, loggerFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected ConfigurablePropertyResolvercreatePropertyResolver(MutablePropertySources propertySources) Create aConfigurablePropertyResolverfor the specified property sources.Return the property sources that were actually applied duringpost-processing.voidpostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) Processing occurs by replacing ${...} placeholders in bean definitions by resolving each against this configurer's set ofPropertySources, which includes: all environment property sources, if anEnvironmentis present merged local properties, if any have been specified any property sources set by callingsetPropertySources(org.springframework.core.env.PropertySources)protected voidprocessProperties(ConfigurableListableBeanFactory beanFactory, Properties props) Deprecated.protected voidprocessProperties(ConfigurableListableBeanFactory beanFactoryToProcess, ConfigurablePropertyResolver propertyResolver) Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties.voidsetEnvironment(Environment environment) Set theEnvironmentthat this component runs in.voidsetPropertySources(PropertySources propertySources) Customize the set ofPropertySourcesto be used by this configurer.Methods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupportdoProcessProperties, setBeanFactory, setBeanName, setEscapeCharacter, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setTrimValues, setValueSeparatorMethods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurerconvertProperties, convertProperty, convertPropertyValue, getOrder, setOrderMethods inherited from class org.springframework.core.io.support.PropertiesLoaderSupportloadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
- 
Field Details- 
LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME"localProperties" is the name given to thePropertySourcefor the set of merged properties supplied to this configurer.- See Also:
 
- 
ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME"environmentProperties" is the name given to thePropertySourcethat wraps the environment supplied to this configurer.- See Also:
 
 
- 
- 
Constructor Details- 
PropertySourcesPlaceholderConfigurerpublic PropertySourcesPlaceholderConfigurer()
 
- 
- 
Method Details- 
setPropertySourcesCustomize the set ofPropertySourcesto be used by this configurer.Setting this property indicates that environment property sources and local properties should be ignored. 
- 
setEnvironmentSet theEnvironmentthat this component runs in.PropertySourcesfrom the givenEnvironmentwill be searched when replacing ${...} placeholders.
- 
postProcessBeanFactorypublic void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException Processing occurs by replacing ${...} placeholders in bean definitions by resolving each against this configurer's set ofPropertySources, which includes:- all environment property sources, if an Environmentis present
- merged local properties, if any have been specified
- any property sources set by calling setPropertySources(org.springframework.core.env.PropertySources)
 If setPropertySources(org.springframework.core.env.PropertySources)is called, environment and local properties will be ignored. This method is designed to give the user fine-grained control over property sources, and once set, the configurer makes no assumptions about adding additional sources.- Specified by:
- postProcessBeanFactoryin interface- BeanFactoryPostProcessor
- Overrides:
- postProcessBeanFactoryin class- PropertyResourceConfigurer
- Parameters:
- beanFactory- the bean factory used by the application context
- Throws:
- BeansException- in case of errors
 
- all environment property sources, if an 
- 
createPropertyResolverprotected ConfigurablePropertyResolver createPropertyResolver(MutablePropertySources propertySources) Create aConfigurablePropertyResolverfor the specified property sources.The default implementation creates a PropertySourcesPropertyResolver.- Parameters:
- propertySources- the property sources to use
- Since:
- 6.0.12
 
- 
processPropertiesprotected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, ConfigurablePropertyResolver propertyResolver) throws BeansException Visit each bean definition in the given bean factory and attempt to replace ${...} property placeholders with values from the given properties.- Throws:
- BeansException
 
- 
processProperties@Deprecated protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) Deprecated.Implemented for compatibility withPlaceholderConfigurerSupport.- Specified by:
- processPropertiesin class- PropertyResourceConfigurer
- Parameters:
- beanFactory- the BeanFactory used by the application context
- props- the Properties to apply
- Throws:
- UnsupportedOperationException- in this implementation
 
- 
getAppliedPropertySourcesReturn the property sources that were actually applied duringpost-processing.- Returns:
- the property sources that were applied
- Throws:
- IllegalStateException- if the property sources have not yet been applied
- Since:
- 4.0
 
 
- 
processProperties(ConfigurableListableBeanFactory, ConfigurablePropertyResolver)