Loading multiple property files

To load multiple property files using Spring’s PropertyPlaceholderConfigurer, add <property name=”ignoreUnresolvablePlaceholders” value=”true” /> to the one that is loaded first like so:

<bean id=”propertyConfigurer”
<property name=”location” value=”classpath:jdbc.properties” />
<property name=”ignoreUnresolvablePlaceholders” value=”true” />

<bean id=”mailPropertyConfigurer”
<property name=”location” value=”classpath:mail.properties” />

This will make sure both files are loaded. ๐Ÿ™‚

11 thoughts on “Loading multiple property files

  1. Just wanted to point out, it is also possible to use the ‘locations’ property of a single PropertyPlaceholderConfigurer:


  2. with escaped xml this time…
    <bean class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
    <property name=”locations”>

  3. Thanks heaps, multiple files using locations is just what I wanted. btw, In case any punters need to know how to reference properties in spring:


  4. The ignoreUnresolvablePlaceholders is helpful when you have multiple Spring xml configurations file and each needs its own properties file. You can make it work with locations as well but the former is more cleaner IMO.

  5. Use different properties per environment and use your build script to create the build with the appropriate properties file. Good luck!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s