1

当我尝试运行休眠应用程序文件时,它给出的问题是hibernate.cfg.xml. 用于在 DTD 级别解析文件。任何人都可以帮助我解决这个问题。

INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Apr 21, 2017 4:55:09 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2165)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2077)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2056)
    at com.app.main.HibernateTest.main(HibernateTest.java:19)
Caused by: org.dom4j.DocumentException: Error on line 5 of document  : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2157)
    ... 3 more

在 hibernate.cfg.xml 的行中添加以下行

<!DOCTYPE hibernate-configuration PUBLIC  
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Using Hibernate 4.3.11 jars
4

0 回答 0