Declaring
<context:property-placeholder location="classpath:a.properties"/>
registers a PropertySourcesPlaceholderConfigurer
bean and a bean of an inner class of this called PlaceholderResolvingStringValueResolver
. Each of these beans registers a PropertySource
in the Spring Environment
.
Spring, when it has to resolve a String
placeholder ${}
value then iterates through the registered PlaceholderResolvingStringValueResolver
beans. It uses their resolveStringValue
method to resolve the placeholder. If it cannot, it fails fast, even if another PlaceholderResolvingStringValueResolver
could have resolved it.
The solution is to use a single <context:property-placeholder>
where all the properties are registered in one PropertySourcesPlaceholderConfigurer
.
Alternatively, you could declare them with the attribute ignore-unresolvable="true"
. In this case, if one can't resolve it, it won't throw any exceptions. Instead it will try the next one. However, you might find yourself with an unresolved property, so I don't recommend it.