2014-12-05 102 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>