2011-01-19 51 views
1

在我的hibernate.cfg.xml我收到以下错误:错误在hibernate.cfg.xml

引用的文件包含错误(http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd)。欲了解更多信息, 右键单击在问题视图的消息,并选择“显示详细信息...”

当我查看“显示详细信息”我收到此错误:

的标记声明通过文档类型声明包含或指向必须有良好的成形

这里是我的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="connection.url">jdbc:mysql://localhost/test</property> 
    <property name="connection.username">root</property> 
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property> 
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 
    <property name="connection.password">root</property> 
    <property name="hibernate.hbm2ddl.auto">update</property> 
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
    <!-- thread is the short name for 
     org.hibernate.context.ThreadLocalSessionContext 
     and let Hibernate bind the session automatically to the thread 
    --> 
    <property name="current_session_context_class">thread</property> 
    <!-- this will show us all sql statements --> 
    <property name="hibernate.show_sql">true</property> 

    <mapping class="com.event.model.Event"/> 

</session-factory> 
</hibernate-configuration> 
+0

可能的现有解决方案:http://stackoverflow.com/questions/17114046/hibernate-error-possibly-with-dtd-declaration – 2016-06-14 14:01:07

回答

1

更改您的文档类型此:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 
     3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> 
0

我有同样的问题。所以,我的解决方法非常简单。 我对文件做了一些修改。之后,我回复了他们,问题得到解决。由Nithin提供。

相关问题