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中,項目完美運行.

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM