加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

class path resource [beans.xml] cannot be opened because it

发布时间:2020-12-15 23:23:52 所属栏目:百科 来源:网络整理
导读:严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from cla
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist 
at 

在spring与hibernate4整合的时候,报出这样的错误,但是我的beans.xml文件就是在src/test/resources包下放置着,并且我通过@ContextConfiguration("/beans.xml")这个去初始化spring,但是为什么会找不到呢?

错误是:在classpath中没有找到beans.xml文件,于是我很自然的想到去eclipse中的classpath文件中去查看,最终发现确实没有这样一句话:<classpathentry kind="src" path="src/test/resources"/>,那就说明没有把此目录映射的classpath中,此时感到很是不解,难道是eclipse下的maven有问题?解决方法:我把src/test/resources这个目录删掉,然后重新创建了此目录,并且创建了beans.xml文件之后,一切正常!!!

但是目前为止,我也不知道具体为什么会出现这种问题,以上就算是一种解决方法吧!!!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读