Is there a way to specify a default property value in Spring XML?
There is a little known feature, which makes this even better. You can use a configurable default value instead of a hard-coded one, here is an example:
config.properties:
timeout.default=30timeout.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 while still being able to easily override later, do this in config.properties:
timeout.myBean = ${timeout.default}
<foo name="port"> <value>${my.server.port:8088}</value></foo>
should work for you to have 8088 as default port
See also:http://blog.callistaenterprise.se/2011/11/17/configure-your-spring-web-application/