简体   繁体   English

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

[英]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>
  ...
</session-factory>

you have problem with your config file see this <property name="connection.password"/>shaher</property> 您的配置文件有问题,请参见此<property name="connection.password"/>shaher</property>

please update it to below <property name="connection.password">shaher</property> 请将其更新为<property name="connection.password">shaher</property>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.xml.sax.SAXParseException; 文档根元素“ session-factory”,必须与DOCTYPE根“ hibernate-configuration”匹配 - org.xml.sax.SAXParseException; Document root element “session-factory”, must match DOCTYPE root “hibernate-configuration” 无法创建会话工厂。org.hibernate.HibernateException:无法解析配置:/hibernate.cfg.xml - Session Factory could not be created.org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml 休眠配置文件中会话工厂名称属性的用途是什么 - What is the use of session-factory name property in hibernate-configuration file 寻找一个不被弃用的会话工厂 - Looking for a not-deprecated session-factory 元素类型“主机”必须以匹配的结束标记“ </Host> ” - The element type “Host” must be terminated by the matching end-tag “</Host>” 元素类型“META”必须以匹配的结束标签“</META> ” - The element type “META” must be terminated by the matching end-tag “</META>” “会话工厂”必须匹配“(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)” - “session-factory” must match “(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)” SaxParseException 元素类型“hr”必须由匹配的结束标记“终止</hr> “。在使用 jaxb 读取 xml 时 - SaxParseException The element type "hr" must be terminated by the matching end-tag "</hr>". while reading xml with jaxb 无效的 XML:第 6 行错误:元素类型“hr”必须由匹配的结束标记“终止”</hr> ” - Invalid XML: Error on line 6: The element type “hr” must be terminated by the matching end-tag “</hr>” Pom.xml:元素类型“dependencies”必须由匹配的end-tag“”终止 - Pom.xml: The element type “dependencies” must be terminated by the matching end-tag “</dependencies>”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM