【开发错误录】class path resource [SpringMvc.xml] cannot be opened because it does not exist

问题描述:

一个ssm项目,spring 整合 spring mvc,项目启动后页面报如下错误:

在这里插入图片描述

根本原因:

1、org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [SpringMvc.xml]; nested exception is java.io.FileNotFoundException: class path resource [SpringMvc.xml] cannot be opened because it does not exist
2、java.io.FileNotFoundException: class path resource [SpringMvc.xml] cannot be opened because it does not exist

找不到SpringMvc.xml,在下面web.xml中是我引用路径,网上找到问题classpath指向路径不是resource路径,所以一直找不到我的xml文件

 
 
     springMvc
     org.springframework.web.servlet.DispatcherServlet
     
         contextConfigLocation
         classpath:SpringMvc.xml
     
     
     1
 

解决方法:

classpath: 到你的class路径中查找文件;

classpath*: 不仅包含class的路径,还包括jar文件中(class路径)进行查找

> 解决办法:在classpath后面在上“*” 可解决问题,“classpath*:SpringMvc.xml”

 
 
     springMvc
     org.springframework.web.servlet.DispatcherServlet
     
         contextConfigLocation
         classpath*:SpringMvc.xml
     
     
     1
 

你可能感兴趣的:(【开发错误录】class path resource [SpringMvc.xml] cannot be opened because it does not exist)