Could not resolve placeholder

Source: Internet
Author: User

Read the properties profile using Spring's <context:property-placeholder location= "/web-inf/"/> Error Could not Resolve placeholder

Project structure


Start error

Follow this error up and find the. properties file is not fully loaded, is configured to load in Web. XML, Both the and files are configured in the Application.xml file.

From the console you can find that the file is not loaded

Info:set Web App root system property: ' webapp.root ' = [D:\soft\MyEclipse professional2013workspace\.metadata\.me_tcat\ Webapps\zjx-springmvc\] July 24, 2016 12:16:29 am org.apache.catalina.core.ApplicationContext loginfo:initializing log4j From [D:\soft\MyEclipse professional2013workspace\.metadata\.me_tcat\webapps\zjx-springmvc\web-inf\] July 24, 2016 12:16:29 am org.apache.catalina.core.ApplicationContext loginfo:initializing Spring Root Webapplicationcontext[info][2016-07-24 00:16:29] Org.springframework.web.context.ContextLoader.initWebApplicationContext ( Root Webapplicationcontext:initialization started [info][2016-07-24 00:16:30] ( : 578) Refreshing Root webapplicationcontext:startup date [Sun Jul 00:16:30 CST 2016]; Root of context hierarchy [info][2016-07-24 00:16:31] Org.springframework.beans.factory.xml.XmlBeanDefinitionReaDer.loadbeandefinitions ( Loading XML bean Definitions from servletcontext resource [/ Web-inf/applicationcontext.xml] [info][2016-07-24 00:16:35] ( Loading properties file from ServletContext resource [/web-inf/] [warn][2016-07-24 00:16:35] Org.spring ( Exception Encountered during context initialization-cancelling refresh attempt: Org.springframework.beans.factory.BeanDefinitionStoreException:Invalid Bean definition with name ' Jedispoolconfig ' defined in ServletContext resource [/web-inf/applicationcontext.xml]: Could, resolve placeholder ' redis.maxidle ' in St Ring value "${redis.maxidle}"; Nested exception is java.lang.IllegalArgumentException:Could not resolve placeholder ' redis.maxidle ' in string value "${r   Edis.maxidle} "  [ERROR] [2016-07-24 00:16:35] Org.springframework.web.context.ContextLoader.initWebApplicationContext ( : 351) Context initialization failed Org.springframework.beans.factory.BeanDefinitionStoreException:Invalid Bean Defi Nition with name ' jedispoolconfig ' defined in ServletContext resource [/web-inf/applicationcontext.xml]: Could not Resolv E placeholder ' redis.maxidle ' in string value "${redis.maxidle}"; Nested exception is java.lang.IllegalArgumentException:Could not resolve placeholder ' redis.maxidle ' in string value "${r Edis.maxidle} "


In the spring XML configuration file, when there are multiple *.properties files that need to be loaded. Need this

Scenario 1: Not recommended (coupling is too big for splitting projects)

Combine multiple. Properties files into a single. properties file

Scenario 2: Add ignore-unresolvable= "true" in <context:property-placeholder location= "/web-inf/"/>


The spring container uses the discovery mechanism of reflection scanning, which has a org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in the detection of spring containers. The bean will stop scanning the remaining propertyplaceholderconfigurer (Spring 3.1 has used propertysourcesplaceholderconfigurer instead Propertyplaceholderconfigurer).
<context:property-placeholder/>, the namespace-based configuration, actually creates a propertyplaceholderconfigurer bean inside. in other words, the spring container allows only a maximum of one propertyplaceholderconfigurer (or <context:property-placeholder/>) to be defined, The rest will be ignored by spring (in fact, if spring provides a warning).

Scenario 3: Other ways to load resource files

   <BeanClass= "Org.springframework.jdbc.datasource.DriverManagerDataSource">
     <PropertyName= "Locations">
          <Value></Value> </list> </Property> <property name= " Ignoreunresolvableplaceholders " Value=" true " /> </bean>
   <Beanclass= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> < Propertyname= "Locations"> <List> <value></value><!--If this is the class path, load-
<!--<value>/web-inf/</value>--><!-- If this is the Web-info path, load - </List> </ Property> < Propertyname= "Ignoreunresolvableplaceholders"value= "true" /> </Bean>

As long as the ignoreunresolvableplaceholders is guaranteed to be true, or this last load is false, the previous one is true.


Either scenario 2 or scenario three namely: Ignore-unresolvable= "true" and <property name= "Ignoreunresolvableplaceholders" value= "true"/> Both of these property values must be True

Could not resolve placeholder

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: 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.