什么doctype用于hibernate 4

时间:2014-03-04 01:03:59

标签: hibernate

我的问题与此基本相同: functional hibernate.cfg.xml for hibernate 4 但我无法发布信息,因为我没有足够的声望点,而且尚未得到答复。

我正在使用Hibernate 4.3.4和hibernate.cfg.xml文件(在Tomcat 6.0.39中)。在.xml文件的顶部,我有:

<?xml version='1.0' encoding='utf-8'?>

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

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration"  xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

当我尝试创建配置时,出现以下错误:

org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for element type "hibernate-configuration"

在谷歌搜索后,似乎我的DOCTYPE可能出现问题,在我的hibernate文档中,示例.cfg.xml文件根本没有DOCTYPE,所以我尝试删除它,但是我收到这个错误:

org.xml.sax.SAXParseException: Document is invalid: no grammar found

然后我试着看看如何关闭导致这种情况的验证,但我真的宁愿以正确的方式做到这一点。有没有人有hibernate版本4的函数hibernate.cfg.xml文件,或者可能知道我在这里做错了什么蠢事?

谢谢!

1 个答案:

答案 0 :(得分:0)

我发现如果我只删除所有内容,它就可以了。我宁愿让它与没有DOCTYPE的实际文档相匹配,但是现在,我会保留它,因为它正在工作。

相关问题