2011-01-19 56 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提供。

相關問題