java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist

java.io.FileNotFoundException: class path resource ..cannot be opened because it does not exist 
异常如下:
java.io.FileNotFoundException: class path resource [com/jxust/zjh/model/Account.hbm.xml] cannot be opened because it does not exist

在spring中我这样配置<property name="mappingResources">
<list> <value>com/jxust/zjh/model/Account.hbm.xml</value>
</list>
</property>
就报上述错误,Account.hbm.xml确实在此目录下。
但是,我改成这样就运行正常,
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/jxust/zjh/model/</value>
</list>
</property>





解决方案:
1.路径问题,,,,,,直接将配置文件搞到src下面.....因为myeclipse默认会去src下找

最简单的方法还是老老实实把xml放在src下方便。

或者建立config时建立成source folder,,,,就相当于是classpath了


2.此时去查看tomcat中的web-inf下的classes文件夹,查看上面报错的差找不到beans文件是否存在于tomcat中....如果不存在,,,,说明原因在这里

此时需要将tomcat中部署的项目删掉.然后在myeclipse中的项目工程clean一下,然后重新部署,会发现所有文件都部署到了tomcat中,项目完美运行.

  

posted @ 2017-05-06 11:38  猿员  阅读(23493)  评论(0编辑  收藏  举报