6

在 Hibernate 4 中,我发现(对我来说是新的)使用 XSD 模式而不是 DTD 的可能性。

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

但是模式位置无效,在初始化期间我遇到了错误。

有人知道 Hibernate 4 中的 XSD 有什么问题吗?

4

2 回答 2

7
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
 xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping classpath://org/hibernate/hibernate-mapping-4.0.xsd" 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" package="acme.foo.bar"/>

试试这个,它应该会更好。

于 2013-09-11T09:05:23.543 回答
2

架构位置只是地点的标识符,这个地点可以绑定到任何地方:互联网、本地驱动器。特别是这个模式(连同hibernate-configuration-4.0.xsd)被放置在包 org.hibernate 中的 hibernate-core jar 中。由于通常 schemaLocation 和实际位置是相同的,IDE 会尝试从它指向的位置获取它,但这不是我们的情况。您可以配置您的 IDE 以在此 jar 中查找此架构,以便您可以使用自动完成功能。如果我们谈论的是 IntelliJ,请转到设置并配置您的模式和 DTD 以包含所需的模式。

于 2012-03-14T10:12:20.873 回答