2014-12-05 120 views
0

我使用hibernate 4.0和mysql 5.6與eclipse luna(v4.4.1), 我在我的項目中使用hibernate註釋。 當我對DB的任何表進行更改時,我總是通過eclipse hibernate配置自動生成hibernate註釋。 我的問題是: 當我不連接互聯網,並希望生成hibernate註釋我得到這個錯誤:[Classpath]:無法加載AnnotationConfiguration(屏幕截圖還附加),當我連接到互聯網我不面臨這個錯誤。 是這個bug或功能?如果這是功能,那麼我怎麼能離線生成休眠註釋? 謝謝! enter image description here無法加載AnnotationConfiguration休眠,當互聯網沒有連接

的hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC 
     "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 
     "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.password">myroot</property> 
     <property name="hibernate.connection.url">jdbc:mysql://192.168.72.128:3306/hesco</property> 
     <property name="hibernate.connection.username">myroot</property> 
    </session-factory> 
</hibernate-configuration> 

回答

1

你可以嘗試把在當地所需要的所有的DTD。

http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd 

其實你在Hibernate confil文件的URL應該是原因:

192.168.72.128

嘗試本地主機,如果這是你的IP地址。

+0

感謝您節省我的一天,我的問題是如何以及在哪裏(位置)我可以把dtd放在我的項目中? 順便說一句192.168.72.128是我的服務器機器IP,它工作正常。 – 2014-12-05 22:14:09

0

感謝澤維爾Bouclet誰指導我一下DTD的問題,我沒有谷歌,並找到該link

我把下面DOCTYPE的hibernate.cfg.xml文件我的解決方案,現在我可以脫機工作

<!DOCTYPE hibernate-configuration SYSTEM 
    "classpath://org/hibernate/hibernate-configuration-3.0.dtd"> 

的hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration SYSTEM 
    "classpath://org/hibernate/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
     <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
     <property name="hibernate.connection.password">myroot</property> 
     <property name="hibernate.connection.url">jdbc:mysql://192.168.72.128:3306/hesco</property> 
     <property name="hibernate.connection.username">myroot</property> 
    </session-factory> 
</hibernate-configuration>