0

<

!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
4

2 回答 2

0

以下应该是hibernate.cfg.xml文件中的完整 DTD

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

也不要忘记在文件的开头跟随

<?xml version='1.0' encoding='utf-8'?> 
于 2014-08-21T11:30:37.893 回答
0

您的DOCTYPE定义指的DTD是 on hibernate.sourceforge.net。现在 DTD 存在(我可以通过 Firefox 浏览它)但您的应用程序无法访问它。doctype 元素的目的是链接到 DTD。

尝试使用下面

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"classpath://org/hibernate/hibernate-mapping-3.0.dtd">
于 2014-08-21T10:41:48.413 回答