class path resource [spring.xml] cannot be opened because it does not exist

xiaoxiao2021-02-28  31

    使用maven创建web工程,将spring配置文件applicationContext.xml放在src/resource下,用Myeclipse编译时提示class path resource [applicationContext.xml] cannot be opened because it does not exist错误。

web.xml配置的如下

<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param>

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

<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:applicationContext.xml</param-value> </context-param>

转载请注明原文地址: https://www.6miu.com/read-749996.html

最新回复(0)