Spring deployment Error: Could not open ServletContext resource [/db.properties]

Source: Internet
Author: User



During the use of the spring MVC process, the deployment project error, error message is as follows:


August 15, 2016 5:02:04 pm Org.apache.catalina.core.StandardContext listenerstart
Severity: Exception sending context initialized event to listener instance of class Org.springframework.web.context.ContextLoad Erlistener
Org.springframework.beans.factory.BeanInitializationException:Could not load properties; Nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/db.properties]
At Org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory ( propertysourcesplaceholderconfigurer.java:151)
.......
At Org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run (taskthread.java:61)
At Java.lang.Thread.run (Unknown Source)
caused by: java.io.FileNotFoundException:Could not open ServletContext resource [/db.properties]
At Org.springframework.web.context.support.ServletContextResource.getInputStream (Servletcontextresource.java : 141)
At Org.springframework.core.io.support.EncodedResource.getInputStream (encodedresource.java:153)
... Wuyi more


......................................................................................................................... ......................................................



MAVEN projects, Application-context.xml, db.properties files are placed in the Src/main/resources directory, Tomcat deployment project, src/main/ The configuration file under the Resources directory has the default location: {The project name is}/web-inf/classes, but spring is not found in the project root directory, so you can find it by specifying the CLASSPATH directory when configuring.



The solution is as follows:



<context:property-placeholder location= "classpath:db.properties"/>



Spring deployment Error: Could not open ServletContext resource [/db.properties]


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.