could not resolve placeholder ${}

When loading the properties file with spring configuration, a Could not resolve placeholder error is reported.
It is very likely that multiple PropertyPlaceholderConfigurers or multiple <context:property-placeholder>s are used or multiple PropertyPlaceholderConfigurers are mixed with <context:property-placeholder>.
Solution:
In Spring3, it can be solved in the following way, find all <context:property-placeholder> and
add ignore-unresolvable="true" attribute, note that it must be added
<context:property-placeholder location="xxx.properties" ignore-unresolvable="true"  />  


In Spring 2.5, <context:property-placeholder> does not have the ignore-unresolvable property, so PropertyPlaceholderConfigurer can be used instead. In fact, <context:property-placeholder location="xxx.properties" ignore-unresolvable="true" /> is equivalent to the following configuration
<bean id="XX" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
    <property name="location" value="xxx.properties" />  
    <property name="ignoreUnresolvablePlaceholders" value="true" />   
</bean>  


This error is because <property name="ignoreUnresolvablePlaceholders" value="true" /> is configured and <context:property-placeholder location="xxx.properties" ignore-unresolvable="true" /> is not configured

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327081347&siteId=291194637