Using multiple property files (via PropertyPlaceholderConfigurer) in multiple projects/modules Using multiple property files (via PropertyPlaceholderConfigurer) in multiple projects/modules java java

Using multiple property files (via PropertyPlaceholderConfigurer) in multiple projects/modules


If you ensure that every place holder, in each of the contexts involved, is ignoring unresolvable keys then both of these approaches work. For example:

<context:property-placeholderlocation="classpath:dao.properties,          classpath:services.properties,          classpath:user.properties"ignore-unresolvable="true"/>

or

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">        <property name="locations">            <list>                <value>classpath:dao.properties</value>                <value>classpath:services.properties</value>                <value>classpath:user.properties</value>            </list>        </property>         <property name="ignoreUnresolvablePlaceholders" value="true"/>    </bean>


I know that this is an old question, but the ignore-unresolvable property was not working for me and I didn't know why.

The problem was that I needed an external resource (something like location="file:${CATALINA_HOME}/conf/db-override.properties") and the ignore-unresolvable="true" does not do the job in this case.

What one needs to do for ignoring a missing external resource is:

ignore-resource-not-found="true"

Just in case anyone else bumps into this.


You can have multiple <context:property-placeholder /> elements instead of explicitly declaring multiple PropertiesPlaceholderConfigurer beans.