spring-framework / org.springframework.context.support / PropertySourcesPlaceholderConfigurer

PropertySourcesPlaceholderConfigurer

open class PropertySourcesPlaceholderConfigurer : PlaceholderConfigurerSupport, EnvironmentAware

Specialization of 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 in Spring 3.1 applications. It is used by default to support the property-placeholder element in working against the spring-context-3.1 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 (e.g. those added via #setProperties, #setLocations et al.) are added as a 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 org.springframework.core.env.ConfigurableEnvironment and related javadocs for details on manipulating environment property sources.

Author
Chris Beams

Since
3.1

See Also
org.springframework.core.env.ConfigurableEnvironmentorg.springframework.beans.factory.config.PlaceholderConfigurerSupportorg.springframework.beans.factory.config.PropertyPlaceholderConfigurer

Constructors

<init>

PropertySourcesPlaceholderConfigurer()

Specialization of 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 in Spring 3.1 applications. It is used by default to support the property-placeholder element in working against the spring-context-3.1 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 (e.g. those added via #setProperties, #setLocations et al.) are added as a 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 org.springframework.core.env.ConfigurableEnvironment and related javadocs for details on manipulating environment property sources.

Properties

ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME

static val ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME: String

{@value} is the name given to the PropertySource that wraps the environment supplied to this configurer.

LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME

static val LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME: String

{@value} is the name given to the PropertySource for the set of merged properties supplied to this configurer.

Functions

getAppliedPropertySources

open fun getAppliedPropertySources(): PropertySources

Returns the property sources that were actually applied during post-processing.

postProcessBeanFactory

open fun postProcessBeanFactory(beanFactory: ConfigurableListableBeanFactory): Unit

{@inheritDoc}

Processing occurs by replacing ${...} placeholders in bean definitions by resolving each against this configurer's set of PropertySources, which includes:

If #setPropertySources 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.

setEnvironment

open fun setEnvironment(environment: Environment): Unit

{@inheritDoc}

PropertySources from this environment will be searched when replacing ${...} placeholders.

setPropertySources

open fun setPropertySources(propertySources: PropertySources): Unit

Customize the set of PropertySources to be used by this configurer. Setting this property indicates that environment property sources and local properties should be ignored.