2014-04-13 51 views
0

我想運行我的第一個休眠程序。 我不明白這個問題,因爲匹配的結束標籤實際上在那裏? 感謝您的幫助提前!XML解析錯誤 - 休眠

Error parsing XML: /hibernate.cfg.xml(11) The element type "session-factory" must be terminated by the matching end-tag 

的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> 

     <!-- Database connection settings --> 
     <property name="hibernate.connection.driver_class" /> com.mysql.jdbc.Driver </property> 
     <property name="hibernate.connection.url"/>jdbc:mysql://localhost:3306/westbahn</property> 
     <property name="hibernate.connection.username" />root</property> 
     <property name="hibernate.connection.password" />secretpassword</property> 
     <property name="hibernate.dialect" />org.hibernate.dialect.MySQLInnoDBDialect</property> 




     <property name="connection.pool_size">1</property> 

     <property name="hibernate.dialect"> org.hibernate.dialect.MySQLInnoDBDialect" </property> 

     <property name="show_sql">true</property> 

     <property name="current_session_context_class">thread</property> 
     <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 

     <property name="hibernate.hbm2ddl.auto">create</property> 

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

。在你的XML沒有根的Hibernate配置元素。沒有開放的會話工廠元素。顯示整個文件。從第一行到最後一行。 –

+0

您的'property'標籤爲空:' ...'。從第一個標籤中刪除'/':'' – helderdarocha

+0

非常感謝,它正在工作,這是一個尷尬的錯誤。 – user3319337

回答

0

Hibernate配置文件應該是這樣的

<hibernate-configuration> 
    <session-factory> 
    <property name="connection.driver_class">oracle.jdbc.OracleDriver</property> 
    <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property> 
    <property name="connection.user">xxx</property> 
    <property name="connection.password">xxxx</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property> 
    <property name="show_sql">true</property> 
     <property name="hibernate.hbm2ddl.auto">create</property> 
    <mapping resource="xxxx.hbm.xml"/> 
    </session-factory> 
</hibernate-configuration> 

這可以幫助你!

0

您的5個第一個屬性元素是錯誤的:您使用自閉元素,雖然他們有一個正文。例如:

<property name="hibernate.connection.driver_class" /> com.mysql.jdbc.Driver </property> 

應該

<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property> 
            no slash here --^