无法解析配置:hibernate.cfg.xml:元素类型“session-factory”必须由匹配的结束标记“”终止

时间:2016-04-08 08:55:51

标签: java xml hibernate

我是初学者并尝试运行第一个简单代码。

请帮我解决以下问题。

Error on line 11 of document  : The element type "session-factory" must be terminated by the matching end-tag "</session-factory>". 
Nested exception: The element type "session-factory" must be terminated by the matching end-tag "</session-factory>".
        at org.dom4j.io.SAXReader.read(SAXReader.java:482)

配置文件

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory>
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password"/>shaher</property>
        <property name="connection.pool_size">1</property>
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">create</property>
        <mapping class="org.shaher.hiber.dto.UserDetails"/>
 </session-factory>
</hibernate-configuration>

2 个答案:

答案 0 :(得分:1)

您需要关闭代码<session-factory>

<session-factory>
  ...
</session-factory>

答案 1 :(得分:0)

您的配置文件有问题,请看这个    <property name="connection.password"/>shaher</property>

请将其更新到下面     <property name="connection.password">shaher</property>