Hibernate.cfg.xml解析错误 [英] Hibernate.cfg.xml parsing error
问题描述
!DOCTYPE hibernate-configuration PUBLIC
- // Hibernate / Hibernate Configuration DTD 3.0 / / EN
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">
我在我的hibernate.cfg.xml文件中有这个。我有下载的jar文件(来自 http://www.javatpoint.com/src/hb/ eclipse工作区中WEB-INF文件夹中的hibernatejar.zip )。它仍然说hibernate.sourceforge.net是无法访问的。我用www.hibernate.org/dtd替换它,这也给出了相同的错误。请帮我解决这个问题。
映射文件同样存在问题。
在DOCTYPE中添加classpath后出现错误:
log4j:WARN记录器(org.hibernate.cfg.Environment)中找不到appender。
log4j:WARN请正确初始化log4j系统。
线程main中的异常org.hibernate.HibernateException:无法解析配置:hibernate.cfg.xml
在org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
在org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
在StoreData.main(StoreData.java:12)
引起:org.dom4j.DocumentException:未知协议:classpath嵌套异常:未知协议:类路径
在org.dom4j.io.SAXReader.read(SAXReader.java:484)
在org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2 more
在 hibernate.cfg.xml 文件中完整的DTD
<!DOCTYPE hibernate-configuration PUBLIC
- // Hibernate / Hibernate配置DTD 3.0 // EN
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd\">
另外,请不要忘记在文件的开始部分追加
<?xml version ='1.0'encoding ='utf-8'?>
<
!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
I have this in my hibernate.cfg.xml file. I have the jars downloaded (from http://www.javatpoint.com/src/hb/hibernatejar.zip) in WEB-INF folder in eclipse workspace. Still it says hibernate.sourceforge.net is unreachable. I replaced it with www.hibernate.org/dtd and that is also giving same error. Please help me fix this.
Same issue in mapping file as well.
Error after adding classpath in DOCTYPE:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at StoreData.main(StoreData.java:12)
Caused by: org.dom4j.DocumentException: unknown protocol: classpath Nested exception: unknown protocol: classpath
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2 more
Following should be your complete DTD in hibernate.cfg.xml file
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
Also do not forget following at the start in the file
<?xml version='1.0' encoding='utf-8'?>
这篇关于Hibernate.cfg.xml解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!