Blind Squirrel

Once in a while, even a blind squirrel finds a nut.

Spring PropertyPlaceholderConfigurer Beans

So I found a scenario today where we had two different PropertyPlaceHolderConfigurer beans declared in two separate XML files. Unfortunately, the second property file wasn’t getting loaded, so we would get errors about Spring being unable to resolve particular properties.

I found this great post summarizing the solution:

http://dotal.wordpress.com/2007/09/14/mulitple-propertyplaceholderconfigurer-configurations/

Basically, you have to update the definition for the first PropertyPlaceHolderConfigurer bean that gets loaded and add the ignoreUnresolvablePlaceholders property:

1
2
3
4
<bean id="mailProps" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
         <property name="location" value="classpath:mail.properties"/>
         <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>