在使用Spring MVC过程中,部署项目报错,报错信息如下:

八月 15, 2016 5:02:04 下午 org.apache.catalina.core.StandardContext listenerStart
严重: 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

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

Maven项目,application-context.xml、db.properties文件均放置在src/main/resources目录下,Tomcat部署项目,src/main/resources目录下的配置文件默认位置为:{项目名}/WEB-INF/classes,而Spring却在项目根目录下寻找,肯定找不到,因此,配置时指定classpath目录下寻找即可。

解决方案如下:

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

Spring部署报错:Could not open ServletContext resource [/db.properties]的更多相关文章

  1. HTTP状态 500 - 内部服务器错误之Could not open ServletContext resource [/db.properties]或者 [/mybatis.xml]

    报错原因是因为找不到db.properties或者mybatis.xml,但是我明明写了有.找了一下,才发现spring-dao.xml里面这两个配置文件地址有问题 Maven项目,applicati ...

  2. Openfire 代码部署报错: Variable references non-existent resource:${workspace_loc:openfire_src}

    Variable references non-existent resource:${workspace_loc:openfire_src} -DopenfireHome=“${workspace_ ...

  3. 解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element

    解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element 'beans'.Referenced file conta ...

  4. Spring Boot报错 MultipartException The temporary upload...

    Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ...

  5. Spring Boot 报错记录

    Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ...

  6. Spring.之.报错:Caused by: java.lang.IllegalArgumentException: No Spring Session store is configured: set the 'spring.session.store-type' property

    Spring.之.报错 No Spring Session store is configured springboot在启动的时候报如下错误: Error starting ApplicationC ...

  7. ionic报错: Failed to load resource

    隔了一天,才发现是代码写错了 出错的原因是在ts 文件中使用这样的定义 data: [] = ['高新区', '经开区', '其他园区']; 错误在于这个定义的类型,不能是 [],修改成 any就没有 ...

  8. Nginx反向代理上传大文件报错(failed to load resource : net :: ERR_CONNECTION_RESET)

    转自: https://blog.csdn.net/kinginblue/article/details/50753271?locationNum=14&fps=1 Nginx反向代理上传大文 ...

  9. Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')

    Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...

随机推荐

  1. React.Fragment 的作用:代替div作为外层

    https://segmentfault.com/a/1190000013220508 import React, { Fragment } from 'react'; <Fragment> ...

  2. Response.ContentType 详细列表-请求的内容类型详细记录

    Response.ContentType 详细列表-请求的内容类型详细记录 作者:王春天一.应用实例: Response.Clear(); Response.ContentType = "t ...

  3. mysql如何查找某字段所在表

    如果是5.0以上的,以root用户连接,可以看到一个叫information_schema的表, 然后只要:use information_schema; select `TABLE_NAME`fro ...

  4. ZYSocket 4.2.3 SOCKET框架组 发布[NEW]

    http://blog.csdn.net/luyikk/article/details/6099337

  5. Serviceability

    http://hg.openjdk.java.net/jdk7u/jdk7u2/hotspot/file/6259c6d3bbb7/agent/doc/clhsdb.html http://blog. ...

  6. jenkins结合脚本实现代码自动化部署及一键回滚至上一版本

    持续集成之⑤:jenkins结合脚本实现代码自动化部署及一键回滚至上一版本 一:本文通过jenkins调用shell脚本的的方式完成从Git服务器获取代码.打包.部署到web服务器.将web服务器从负 ...

  7. 【RapidIO相关】DSP与FPGA通信

    TI参考链接: http://www.ti.com.cn/general/cn/docs/gencontent.tsp?contentId=50741 ------------------------ ...

  8. 每日英语:Is It Possible To Reason About Having A Child?

    How can you decide whether to have a child? It's a complex and profound question -- a philosophical ...

  9. u-boot中添加自定义命令

    1.u-boot命令机制u-boot中,每个命令都使用一个struct cmd_tbl_s结构体定义,该定义在include/command.h中实现:struct cmd_tbl_s{ char * ...

  10. 如何读取jar包外的properties文件和log4j.properties

    http://jrails.iteye.com/blog/1705464 ***************************************' 一般在项目中使用properties配置文件 ...