微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

严重: 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文件之后,一切正常!!!

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

原文地址:https://www.jb51.cc/xml/299779.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。