In the process of using Spring MVC, the deployment project reports an error, and the error message is as follows:
Agu 15, 2016 5:02:04 PM org.apache.catalina.core.StandardContext listenerStart
warning: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
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)
… 51 more
………………………………………….. ………………………………………….. ………………………………………….. …………………….
For the Maven project, the application-context.xml and db.properties files are all placed in the src/main/resources directory. For the Tomcat deployment project, the default location of the configuration file in the src/main/resources directory is: {project name}/WEB-INF /classes, but Spring looks for it in the root directory of the project, and it is definitely not found. Therefore, you can find it in the classpath directory when configuring it.
The solution is as follows:
<context:property-placeholder location=”classpath:db.properties” />
Read More:
- Fuel9.0 deployment openstack error: Deployment has failed,All nodes are finishedFailed task:Task[netconfig/1]
- [Solved] error: db5 error(11) from dbenv->open: Resource temporarily unavailable
- [How to Fix] Spring boot startup error: could not resolve placeholder
- How to Fix Error when integrating spring cloud openfeign with spring cloud Alibaba
- [How to Fix] manual close is not allowed over a Spring managed SqlSession
- [Solved] AAPT: error: resource android:attr/lStar not found
- How to Solve Error: java.io.IOException: Resource [classpath:shiro.ini] could not be found.
- [Solved] fatal error C1083: Could Not Open Unable to open include file:“stdint.h”: No such file or directory
- error: resource android:attr/lStar not found [How to Solve]
- [Solved] Flutter – AAPT: error: resource android:attr/dialogCornerRadius not found.
- error: resource android:attr/lStar not found [How to Solve]
- error: resource android:attr/lStar not found [Pefect Solution]
- Vue Browser Error: Failed to load resource: the server responded with a status of 404 (Not Found)
- [Solved] SSM Project Error: Error during artifact deployment. See server log for details.
- [Solved] Compile Error: AAPT: error: resource android:attr/lStar not found
- [Solved] jedis Error: Could not get a resource from the pool
- error: resource android:attr/lStar not found? [How to Solve]
- [Solved] Error: Could not open client transport with JDBC Uri
- K8S error validating data: ValidationError(Deployment.spec): missing required field selector
- Flutter Error: dump failed because resource AndroidManifest.xml not found [How to Solve]