Spring部署报错:Could not open ServletContext resource [/db.properties]
在使用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]的更多相关文章
- HTTP状态 500 - 内部服务器错误之Could not open ServletContext resource [/db.properties]或者 [/mybatis.xml]
		报错原因是因为找不到db.properties或者mybatis.xml,但是我明明写了有.找了一下,才发现spring-dao.xml里面这两个配置文件地址有问题 Maven项目,applicati ... 
- Openfire 代码部署报错: Variable references non-existent resource:${workspace_loc:openfire_src}
		Variable references non-existent resource:${workspace_loc:openfire_src} -DopenfireHome=“${workspace_ ... 
- 解决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 ... 
- Spring Boot报错 MultipartException The temporary upload...
		Spring Boot报错:尤其是在处理Ribbon这类接口调用型的负载均衡组件,常见问题 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.se ... 
- Spring Boot 报错记录
		Spring Boot 报错记录 由于新建的项目没有配置数据库连接启动报错,可以通过取消自动数据源自动配置来解决 解决方案1: @SpringBootApplication(exclude = Dat ... 
- 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 ... 
- ionic报错: Failed to load resource
		隔了一天,才发现是代码写错了 出错的原因是在ts 文件中使用这样的定义 data: [] = ['高新区', '经开区', '其他园区']; 错误在于这个定义的类型,不能是 [],修改成 any就没有 ... 
- Nginx反向代理上传大文件报错(failed to load resource : net :: ERR_CONNECTION_RESET)
		转自: https://blog.csdn.net/kinginblue/article/details/50753271?locationNum=14&fps=1 Nginx反向代理上传大文 ... 
- Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')
		Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ... 
随机推荐
- java jsch 登录linux系统避免手动输入Yes 或Always
			java jsch方法 登录linux系统, 要手动输入Yes No Always The host 10.202.84.7 is currently unknown to the system Th ... 
- sql 跨表修改的方式
			update xhj_mon_job_log a set person_id = (select id from xhj_mon_job_manage b where a.task_id = b.id ... 
- gitbook安装与使用
			废话不说,直接主题: gitbook安装 =========== 1. 安装npm 从站点 https://nodejs.org/#download 下载node.js源码(点击绿色的INSTALL ... 
- zabbix 源
			http://repo.zabbix.com/ # cat /etc/yum.repos.d/zabbix.repo [zabbix] name=Zabbix Official Repository ... 
- #pragma GCC system_header用法
			在看公司公共库的头文件中发现了:#pragma GCC system_header一行,以前没有见过这种用法,在网上查了一下,解释如下: 从#pragma GCC system_header直到文件结 ... 
- Ubuntu 12.04安装和设置SSH服务
			OpenSSH 是 SSH (Secure SHell) 协议的免费开源实现.SSH协议族可以用来进行远程控制, 或在计算机之间传送文件.而实现此功能的传统方式,如telnet(终端仿真协议). rc ... 
- Oracle PLSQL Demo - 14.定义定参数的显示游标
			declare v_empno scott.emp.empno%type; v_sal scott.emp.sal%type; ) is select t.empno, t.sal from scot ... 
- 使用tesseract-ocr破解网站验证码
			首先我得承认,关注tesseract-ocr, 是冲着下面这篇文章的噱头去的,26行groovy代码破解网站验证码 http://www.kellyrob99.com/blog/2010/03/14/ ... 
- WPF学习之X名称空间详解
			X名称空间里面的成员(如X:Name,X:Class)都是写给XAML编译器看的.用来引导XAML代码将XAML代码编译为CLR代码. 4.1X名称空间里面到底都有些什么? x名称空间映射的是:htt ... 
- 一个div宽度不固定的左右居中效果
			html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,bi ... 
