[transfer] could not resolve placeholder solution

Explain the function of static keyword and final keyword in Java in detail>>>

When the spring configuration loads the properties file, the

Could not resolve placeholder error

After careful searching, the reasons for the errors in file path and file class capacity are excluded. After searching for relevant information, “could not resolve placeholder” is likely to be the use of multiple propertyplaceholder configurators or multiple & lt; context:property-placeholder> Or multiple propertyplaceholder configurators and & lt; context:property-placeholder> Mixed use

If the configuration is as follows, the above error will be reported, whether in multiple configuration files or in different files

<context:property-placeholderlocation="WEB-INF/config/db/XX.properties"/><context:property-placeholderlocation="WEB-INF/config/dfs/XX.properties"/>

Solution:
in spring 3, you can solve the problem in the following ways: add the attribute ignore unresolved = “true”, and pay attention to add it

<context:property-placeholderlocation="xxx.properties"ignore-unresolvable="true"/><context:property-placeholderlocation="yyy.properties"ignore-unresolvable="true"/>

In spring 2.5, & lt; context:property-placeholder> If there is no ignore unresolved property, you can use propertyplaceholderconfigurer instead. Actually & lt; context:property-placeholder location= “xxx.properties”ignore-unresolvable=”true”/> It is equivalent to the following configuration

<beanid="XX"class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><propertyname="location"value="xxx.properties"/><propertyname="ignoreUnresolvablePlaceholders"value="true"/></bean>

If the above error is reported in the system, it can be found as follows: search all the files containing property placeholders in the system to see if they contain the ignore unresolved property, and then search all the files containing property placeholder configurator in the system to see if they contain the ignore unresolved placeholders property

Today, the system reported the above error because it did not configure the ignoreunresolved placeholders property according to the propertyplaceholder configurator method, but instead, according to the context:property-placeholder Methods are configured to include the ignore unresolved attribute



in the final analysis, the specification is not in place, and the loading configuration file is not unified

Similar Posts: