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

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

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念