public class DefaultPropertyPlaceholderConfigurer
extends org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
The default syntax uses an equals sign ('=') to separate the placeholder name from the default value. This syntax mimicks the syntax which would be used in a property file.
Example:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${driver=com.mysql.jdbc.Driver}"/>
<property name="url" value="jdbc:${dbname=mysql:mydb}"/>
</bean>
Having a default value directly inside the bean definition file, at the place where the property is set, avoids redundantly listing the placeholder names. It is most useful for properties that usually keep their default value and are rarely customized outside the bean definition file.
The lookup order for properties and locations is exactly as described in PropertyPlaceholderConfigurer.
The default value is only used if none of the specified properties and locations contains a value for
the placeholder. If no default value is specified, this class behaves exactly the same as its superclass.
PropertyPlaceholderConfigurer,
setDefaultSeparator(java.lang.String)| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_DEFAULT_SEPARATOR |
SYSTEM_PROPERTIES_MODE_FALLBACK, SYSTEM_PROPERTIES_MODE_NEVER, SYSTEM_PROPERTIES_MODE_OVERRIDEDEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, valueSeparator| Constructor and Description |
|---|
DefaultPropertyPlaceholderConfigurer() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
getDefault(String placeholderWithDefault)
extract the default value from the complete placeholder (the part between separator and suffix).
|
protected String |
getPlaceholder(String placeholderWithDefault)
extract the placeholder name from the complete placeholder string (between prefix and separator,
or complete placeholder if no separator is found).
|
protected String |
resolvePlaceholder(String placeholderWithDefault,
Properties props,
int systemPropertiesMode) |
void |
setDefaultSeparator(String def)
Set the string that separates a placeholder name from the default value.
|
parseStringValue, processProperties, resolvePlaceholder, resolveSystemProperty, setSearchSystemEnvironment, setSystemPropertiesMode, setSystemPropertiesModeNamedoProcessProperties, setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparatorconvertProperties, convertProperty, convertPropertyValue, getOrder, postProcessBeanFactory, setOrderpublic static final String DEFAULT_DEFAULT_SEPARATOR
public DefaultPropertyPlaceholderConfigurer()
public final void setDefaultSeparator(String def)
def - separatorDEFAULT_DEFAULT_SEPARATORprotected final String resolvePlaceholder(String placeholderWithDefault, Properties props, int systemPropertiesMode)
resolvePlaceholder in class org.springframework.beans.factory.config.PropertyPlaceholderConfigurerplaceholderWithDefault - default placeholderprops - properties instancesystemPropertiesMode - system properties modeprotected final String getPlaceholder(String placeholderWithDefault)
placeholderWithDefault - default placeholderPlaceholderConfigurerSupport.setPlaceholderPrefix(java.lang.String),
setDefaultSeparator(java.lang.String),
PlaceholderConfigurerSupport.setPlaceholderSuffix(java.lang.String)protected final String getDefault(String placeholderWithDefault)
placeholderWithDefault - PlaceholderConfigurerSupport.setPlaceholderPrefix(java.lang.String),
setDefaultSeparator(java.lang.String),
PlaceholderConfigurerSupport.setPlaceholderSuffix(java.lang.String)Copyright © 2015–2016 Baidu. All rights reserved.