【问题标题】:Could not parse configuration: hibernate.cfg.xml: The element type "session-factory" must be terminated by the matching end-tag "</session-factory>"无法解析配置:hibernate.cfg.xml:元素类型“session-factory”必须由匹配的结束标记“</session-factory>”终止
【发布时间】:2016-04-08 08:55:51
【问题描述】:

我是一个初学者,正在尝试运行第一个简单的代码。

请帮我解决以下问题。

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>

【问题讨论】:

    标签: java xml hibernate


    【解决方案1】:

    你需要关闭标签&lt;session-factory&gt;

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

    【讨论】:

    • @shaher 那么它现在可以工作了吗?如果没有更新您的问题。
    • 它不工作...关闭
    • @shaher 请用封闭标签更新您的问题并添加新的堆栈跟踪错误。
    • @shaher 将最后一个 &lt;/session-factory&gt; 从开头替换为 &lt;session-factory&gt; 并将 / 添加到它。
    【解决方案2】:

    你的配置文件有问题,看这个 &lt;property name="connection.password"/&gt;shaher&lt;/property&gt;

    请更新到下面 &lt;property name="connection.password"&gt;shaher&lt;/property&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 2010-12-18
      • 1970-01-01
      相关资源
      最近更新 更多