获取org.hibernate.HibernateException:无法解析配置:/hibernate.cfg.xml

时间:2017-04-21 11:42:38

标签: hibernate hibernate.cfg.xml

当我尝试运行hibernate应用程序文件时,它给出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

0 个答案:

没有答案