[Switch] cocould not resolve placeholder Solution

Source: Internet
Author: User

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

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.