org.springframework.context.support.PropertySourcesPlaceholderConfigurer
instead which is more flexible through taking advantage of the Environment
and PropertySource
mechanisms.@Deprecated public class PropertyPlaceholderConfigurer extends PlaceholderConfigurerSupport
PlaceholderConfigurerSupport
subclass that resolves ${...} placeholders against
local
properties
and/or system properties
and environment variables.
PropertyPlaceholderConfigurer
is still appropriate for use when:
spring-context
module is not available (i.e., one is using Spring's
BeanFactory
API as opposed to ApplicationContext
).
"systemPropertiesMode"
and/or "systemPropertiesModeName"
properties.
Users are encouraged to move away from using these settings, and rather configure property
source search order through the container's Environment
; however, exact preservation
of functionality may be maintained by continuing to use PropertyPlaceholderConfigurer
.
setSystemPropertiesModeName(java.lang.String)
,
PlaceholderConfigurerSupport
,
PropertyOverrideConfigurer
Modifier and Type | Field and Description |
---|---|
static int |
SYSTEM_PROPERTIES_MODE_FALLBACK
Deprecated.
Check system properties if not resolvable in the specified properties.
|
static int |
SYSTEM_PROPERTIES_MODE_NEVER
Deprecated.
Never check system properties.
|
static int |
SYSTEM_PROPERTIES_MODE_OVERRIDE
Deprecated.
Check system properties first, before trying the specified properties.
|
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, trimValues, valueSeparator
localOverride, localProperties, logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
PropertyPlaceholderConfigurer()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
processProperties(ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props)
Deprecated.
Visit each bean definition in the given bean factory and attempt to replace ${...} property
placeholders with values from the given properties.
|
protected String |
resolvePlaceholder(String placeholder,
Properties props)
Deprecated.
Resolve the given placeholder using the given properties.
|
protected String |
resolvePlaceholder(String placeholder,
Properties props,
int systemPropertiesMode)
Deprecated.
Resolve the given placeholder using the given properties, performing
a system properties check according to the given mode.
|
protected String |
resolveSystemProperty(String key)
Deprecated.
Resolve the given key as JVM system property, and optionally also as
system environment variable if no matching system property has been found.
|
void |
setSearchSystemEnvironment(boolean searchSystemEnvironment)
Deprecated.
Set whether to search for a matching system environment variable
if no matching system property has been found.
|
void |
setSystemPropertiesMode(int systemPropertiesMode)
Deprecated.
Set how to check system properties: as fallback, as override, or never.
|
void |
setSystemPropertiesModeName(String constantName)
Deprecated.
Set the system property mode by the name of the corresponding constant,
e.g.
|
doProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setTrimValues, setValueSeparator
convertProperties, convertProperty, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
public static final int SYSTEM_PROPERTIES_MODE_NEVER
public static final int SYSTEM_PROPERTIES_MODE_FALLBACK
public static final int SYSTEM_PROPERTIES_MODE_OVERRIDE
public void setSystemPropertiesModeName(String constantName) throws IllegalArgumentException
constantName
- name of the constantIllegalArgumentException
setSystemPropertiesMode(int)
public void setSystemPropertiesMode(int systemPropertiesMode)
The default is "fallback": If not being able to resolve a placeholder with the specified properties, a system property will be tried. "override" will check for a system property first, before trying the specified properties. "never" will not check system properties at all.
public void setSearchSystemEnvironment(boolean searchSystemEnvironment)
Default is "true". Switch this setting off to never resolve placeholders against system environment variables. Note that it is generally recommended to pass external values in as JVM system properties: This can easily be achieved in a startup script, even for existing environment variables.
@Nullable protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode)
The default implementation delegates to resolvePlaceholder
(placeholder, props)
before/after the system properties check.
Subclasses can override this for custom resolution strategies, including customized points for the system properties check.
placeholder
- the placeholder to resolveprops
- the merged properties of this configurersystemPropertiesMode
- the system properties mode,
according to the constants in this classsetSystemPropertiesMode(int)
,
System.getProperty(java.lang.String)
,
resolvePlaceholder(String, java.util.Properties)
@Nullable protected String resolvePlaceholder(String placeholder, Properties props)
Subclasses can override this for customized placeholder-to-key mappings or custom resolution strategies, possibly just using the given properties as fallback.
Note that system properties will still be checked before respectively after this method is invoked, according to the system properties mode.
placeholder
- the placeholder to resolveprops
- the merged properties of this configurernull
if nonesetSystemPropertiesMode(int)
@Nullable protected String resolveSystemProperty(String key)
key
- the placeholder to resolve as system property keynull
if not foundsetSearchSystemEnvironment(boolean)
,
System.getProperty(String)
,
System.getenv(String)
protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException
processProperties
in class PropertyResourceConfigurer
beanFactoryToProcess
- the BeanFactory used by the application contextprops
- the Properties to applyBeansException
- in case of errors