The Spring 3.1 PropertySourcesPlaceholderConfigurer
javadoc says:
This class is designed as a general replacement for
PropertyPlaceholderConfigurer
in Spring 3.1 applications.
But I don't see an obvious way to replicate the functionality of PropertyPlaceholderConfigurer
's searchSystemEnvironment property, which makes the configurer look for an environment variable when no system property matching the placeholder name can be found.
Note that I've seen a lot of questions on SO asking about "environment variables" and PropertySourcesPlaceholderConfigurer
but every one I've seen is actually asking about system properties, not environment variables.
How can I tell PropertySourcesPlaceholderConfigurer
to fall back to supplying placeholder values using environment variables?
Firs thing to note is this snippet from the Javadoc
In other words, the
PropertySourcesPlaceholderConfigurer
has its own local property sources, which it searches, by default, after the property sources registered directly in the environment, ie. an instance of typeConfigurableEnvironment
.The Javadoc of
ConfigurableEnvironment
, ingetSystemPropeties()
andgetSystemEnvironment()
, goes on to say thatThese
Environment
implementations areStandardEnvironment
, which is the default Spring'sApplicationContext
classes use.This class Javadoc states
These property sources are mutable and re-orderable. But, to answer your question, the behavior you're requesting is already provided by default.