简体   繁体   中英

Could not parse configuration: hibernate.cfg.xml: The element type “session-factory” must be terminated by the matching end-tag “</session-factory>”

I am a beginner and trying to run first simple code.

Please help me resolve the following issue.

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)

config file

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

You need to close the tag <session-factory>

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

you have problem with your config file see this <property name="connection.password"/>shaher</property>

please update it to below <property name="connection.password">shaher</property>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM