Is there a way to specify a default property value in Spring XML?

Rog picture Rog · Mar 25, 2010 · Viewed 133.2k times · Source

We are using a PropertyPlaceholderConfigurer to use java properties in our Spring configuration (details here)

eg:

<foo name="port">
  <value>${my.server.port}</value>
</foo>

We would like to add an additional property, but have a distributed system where existing instances could all use a default value. Is there a way to avoid updating all of our properties files, by indicating a default value in the Spring config for when there isn't an overriding property value defined?

Answer

lexicore picture lexicore · Mar 29, 2010

Spring 3 supports ${my.server.port:defaultValue} syntax.