There is a little known feature that makes it even better. You can use a custom default instead of hard-coded, here is an example:
config.properties:
timeout.default=30 timeout.myBean=60
context.xml:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>config.properties</value> </property> </bean> <bean id="myBean" class="Test"> <property name="timeout" value="${timeout.myBean:${timeout.default}}" /> </bean>
To use the default value, although it can still be easily overridden later, do this in config.properties:
timeout.myBean = ${timeout.default}
Michael Bรถckling Jun 26 '14 at 16:40 2014-06-26 16:40
source share