【发布时间】:2014-08-21 10:34:10
【问题描述】:
!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
我的 hibernate.cfg.xml 文件中有这个。我在 Eclipse 工作区的 WEB-INF 文件夹中下载了 jars(来自http://www.javatpoint.com/src/hb/hibernatejar.zip)。它仍然说 hibernate.sourceforge.net 无法访问。我用 www.hibernate.org/dtd 替换了它,这也给出了同样的错误。请帮我解决这个问题。
映射文件中也存在同样的问题。
在 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
【问题讨论】:
-
您的库是否存在于您的应用程序类路径中?
-
我已将 jars 添加到 WEB-INF/lib 文件夹中。除此之外,我还在 java 构建路径中添加了它们。
-
看看我的回答。
标签: hibernate hibernate.cfg.xml