Is this possible to se开发者_如何学Got a spring bean's properties through a dot notation in a .properties file. For example suppose you have defined:
<bean name="myBean" class="MyBean" />
Is it possible to set MyBean.someProperty of myBean to a value defined in a properties file? For example by this properties file:
myBean.someProperty = aValue
I know about PropertyPlaceholderConfigurer, but my requirement is somewhat different from what it supports.
If you have a property in your xml like that, you can assign a value from a properties file like that
<property name="someProperty" value="${myBean.someProperty}" />
which has to deal with the PropertyPlaceholderConfigurer
But I think, you want to override your properties, so have a look at the documentation of the PropertyOverrideConfigurer
<context:property-placeholder location="classpath:/application.properties" />
<property name="myProperty" value="${myProperty.key.of.properties}" />
There's also a PropertyOverrideConfigurer
available in the Spring distribution which does exactly what you're looking for.
精彩评论