Configuration lines are expected to be of the following form:
beanName.property=valueExample properties file:
dataSource.driverClassName=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql:mydbIn contrast to PropertyPlaceholderConfigurer, the original definition can have default values or no values at all for such bean properties. If an overriding properties file does not have an entry for a certain bean property, the default context definition is used.
Note that the context definition is not aware of being overridden; so this is not immediately obvious when looking at the XML definition file. Furthermore, note that specified override values are always literal values; they are not translated into bean references. This also applies when the original value in the XML bean definition specifies a bean reference.
In case of multiple PropertyOverrideConfigurers that define different values for the same bean property, the last one will win (due to the overriding mechanism).
Property values can be converted after reading them in, through overriding
the convertPropertyValue method. For example, encrypted values
can be detected and decrypted accordingly before processing them.
convertPropertyValue, PropertyPlaceholderConfigurer
| Modifier and Type | Field and Description |
|---|---|
| private final Set | beanNames
Contains names of beans that have overrides. |
| private String | |
| public static final String | DEFAULT_BEAN_NAME_SEPARATOR
The default bean name separator. |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value)
Apply the given property value to the corresponding bean. |
| public boolean | Returns: whether there were property overrides for the named beanname of the bean to query status for beanName)Were there overrides for this bean? |
| protected void | processKey(ConfigurableListableBeanFactory factory, String key, String value)
Process the given key as 'beanName.property' entry. |
| protected void | processProperties(ConfigurableListableBeanFactory
the BeanFactory used by the application context beanFactory, Properties the Properties to apply props)Implements abstract org. Apply the given Properties to the given BeanFactory. |
| public void | setBeanNameSeparator(String beanNameSeparator)
Set the separator to expect between bean name and property path. |
| public void |
| beanNames | back to summary |
|---|---|
| private final Set<String> beanNames Contains names of beans that have overrides. | |
| beanNameSeparator | back to summary |
|---|---|
| private String beanNameSeparator | |
| DEFAULT_BEAN_NAME_SEPARATOR | back to summary |
|---|---|
| public static final String DEFAULT_BEAN_NAME_SEPARATOR The default bean name separator. | |
| ignoreInvalidKeys | back to summary |
|---|---|
| private boolean ignoreInvalidKeys | |
| PropertyOverrideConfigurer | back to summary |
|---|---|
| public PropertyOverrideConfigurer() | |
| applyPropertyValue | back to summary |
|---|---|
| protected void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value) Apply the given property value to the corresponding bean. | |
| hasPropertyOverridesFor | back to summary |
|---|---|
| public boolean hasPropertyOverridesFor(String beanName) Were there overrides for this bean? Only valid after processing has occurred at least once.
| |
| processKey | back to summary |
|---|---|
| protected void processKey(ConfigurableListableBeanFactory factory, String key, String value) throws BeansException Process the given key as 'beanName.property' entry. | |
| processProperties | back to summary |
|---|---|
| protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props) throws BeansException Implements abstract org. Doc from org. Apply the given Properties to the given BeanFactory.
| |
| setBeanNameSeparator | back to summary |
|---|---|
| public void setBeanNameSeparator(String beanNameSeparator) Set the separator to expect between bean name and property path. Default is a dot ("."). | |
| setIgnoreInvalidKeys | back to summary |
|---|---|
| public void setIgnoreInvalidKeys(boolean ignoreInvalidKeys) Set whether to ignore invalid keys. Default is "false". If you ignore invalid keys, keys that do not follow the 'beanName.property' format (or refer to invalid bean names or properties) will just be logged at debug level. This allows one to have arbitrary other keys in a properties file. | |