"Could not resolve placeholder" solution

Source: Internet
Author: User
Tags config

Except for the Properites file path error and spelling errors, it is likely that Could not resolve placeholder is using more than one propertyplaceholderconfigurer or more <context: The reason for property-placeholder>.

For example, I have a dao.xml read dbconnect.properties, and a dfs.xml read dfsmanager.properties, and then Web. XML for unified load two XML files <                   Context-param> <param-name>contextConfigLocation</param-name> <param-value> Web-inf/config/spring/dao.xml, Web-inf/config/spring/dfs.xml </param-value>   ; </context-param>

If you have XML code in these two XML files <!--dao.xml---<context:property-placeholder location= "web-inf/config/db/ Dbconnect.properties "/> <!--dfs.xml-<context:property-placeholder location=" WEB-INF/CONFIG/DFS/DF Smanager.properties "/>

Then, must be out "Could not resolve placeholder".

Be sure to remember to write the XML code directly, whether in a spring file or in the case of multiple spring files being unified load <context:property-placeholder location= ""/> < Context:property-placeholder location= ""/>

is not allowed.

Solution:

(1) In Spring 3.0, you can write: XML code <context:property-placeholder location= "Xxx.properties" ignore-unresolvable= "true"/&G   T <context:property-placeholder location= "Yyy.properties" ignore-unresolvable= "true"/>

Note that all two must be added ignore-unresolvable= "true", one plus the other does not add.

(2),<context:property-placeholder> has no ignore-unresolvable attribute in Spring 2.5, you can use Propertyplaceholderconfigurer instead. In fact <context:property-placeholder location= "Xxx.properties" ignore-unresolvable= "true"/> with the following configuration is equivalent Java code < Bean id= "Casual" class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > <property name= "Location" value= "Xxx.properties"/> <property name= "Ignoreunresolvableplaceholders" value= "true"/> < ;/bean>

Because of this, writing multiple propertyplaceholderconfigurer does not add ignoreunresolvableplaceholders attributes will also be out "Could not resolve placeholder".

Although the two are equivalent, but it is estimated that people still like to write <context:property-placeholder> more, after all, simple. So if it's Spring 3.0, it's easy to use the solution (1), and if it's spring 2.5, it takes a little effort to rewrite it into Propertyplaceholderconfigurer.

P.S. In fact, the name of this property I have never understood ... ignoreunresolvableplaceholders, ignore unresolved placeholders ... What is the placeholder is not resolvable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.