When the spring configuration loads the properties file
Cocould not resolve placeholder error.
After careful searching, the cause of file paths and file class errors is excluded. After searching relevant information, the following error occurs: "cocould not resolve Placeholder" may be caused by the use of multiple propertyplaceholderholder or multiple <context: property-placeholder> is used in combination with <context: Property-placeholder>.
If the configuration is as follows, the above error will be reported, whether in multiple configuration files or in different files
<context:property-placeholder location="WEB-INF/config/db/XX.properties" /> <context:property-placeholder location="WEB-INF/config/dfs/XX.properties" />
Solution:
You can use the following method in spring3 to add the ignore-unresolvable = "true" attribute.
<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" /> <context:property-placeholder location="yyy.properties" ignore-unresolvable="true" />
In spring 2.5, <context: Property-placeholder> does not have the ignore-unresolvable attribute. In this case, you can use propertyplaceholderconfigurer. 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>
If the above error is reported in the system, you can search for all the files in the system that contain property-placeholder to see if they contain the ignore-unresolvable attribute, and then search for all the files that contain propertyplaceholderpolicer in the system, check whether the ignoreunresolvableplaceholders attribute is included.
The above error is reported in the system today because the ignoreunresolvableplaceholders attribute is not configured in the propertyplaceholderholder mode, and the ignore-unresolvable attribute is configured in the context: Property-placeholder mode.
In the final analysis, the specification is not in place and the configuration files are not uniform.
[Switch] cocould not resolve placeholder Solution