org.hibernate.HibernateException: /hibernate.cfg.xml not found等三個問題


初次配置hibernate在myeclipse上:

出現三個問題,怎么都不好使,比對代碼,沒有問題,查看路徑還是沒有問題:

1、org.hibernate.HibernateException: /hibernate.cfg.xml not found

路徑問題:

說找不到我的hibernate.cfg.xml,比對之后發現沒有問題:

配置好后應該是這樣的,然后mapping中要使用當前的文件路徑,把之前的都刪了。

2、This project is not a MyEclipse Hibernate Project. Assuming Hibernate 3 capablites for the configuration editor.;

顯示這個沒做改動,最后自然好使,有的人說還可以配置下:

myeclipse-->add hibernate capabilites -->next-->hibernate config file --> existing -->選擇現有工程存在的hibernate配置文件--> next --> 不生成factory class --> end

更改后我的還是無效,大家可以試試也許你有效。

3、'hibernate.dialect' must be set when no Connection avalable

無奈下我把例子導入了工程中,然后運行,曝出了錯誤是這個,這個錯誤說我沒有對其進行語言識別的配置,然后我把下邊這句加了進去

<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>結構如圖:

然后所有問題都消失了。

 4、在數據庫中要提前建立好

<property name="connection.url">
jdbc:mysql://localhost:3306/liuyang_person_hibernate
</property>

名字為liuyang_person_hibernate(我的是這個),這個的數據庫,然后寫好測試類,運行一下就好使了

5、最終結果

 


免責聲明!

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



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