Spring xml and PropertyPlaceholderConfigurer
In my project I need two property files. The one in src/main/resources/dbconfig.properties keeps the productions database settings and the other in src/test/resources/dbconfig_dev.properties should keep the development settings.
The production settings are loaded in a Spring XML file with the <context:property-placeholder location="classpath:dbconfig.properties" /> element. With this the placeholders in your Spring config will be resolved, e.g. ${db.username}. The test spring context file is importing the production context file and has a <context:property-placeholder... element too, but references the dbconfig_dev.properties. The dev properties have another prefix, test and Spring fails to load the context because it cannot resolve this development properties.
First I thought, that the dbconfig_dev is not on the classpath, but this was not the problem. As I know, it should be possible to define more than one <context:property-placeholder />. But, if one placeholder can not be resolved from one PropertyPlaceholder it will throw an Exception, that a placeholder is unknown. The second placeholder in the test context does not get a change to resolve the placeholders it knows. For this the property setIgnoreUnresolvablePlaceholders must be set for the PropertyPlaceholder-Bean, so that no Exception is thrown.
But my solution to this problem is, I just renamed my dbconfig_dev.properties to the production name dbconfig.properties and Spring picks it up first because it is in the test classpath.