mave配置之spring.xml is not exeist

来源:互联网 发布:C语言new 编辑:程序博客网 时间:2024/05/13 03:48

错误信息:class path resource [spring.xml] cannot be opened because it does not exist

配置文件的位置:\src\main\resources\spring.xml

使用maven install 编译通过,但是启动tomcat的时候还是报错。原因是该配置文件没有编译到容器中去。

web.xml 中配置:

<!-- spring配置文件位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</context-param>

解决办法:

由于classpath不是指向resource路径,导致一直找不到文件。需要在classpath后面加个*,这样就解决问题了。

所以将web.xml中的代码改为:

<!-- spring配置文件位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring.xml</param-value>
</context-param>

 重启编译启动,成功启动项目!

0 0