【问题标题】:New XSD schema in Hibernate 4Hibernate 4 中的新 XSD 架构
【发布时间】:2012-01-24 18:45:41
【问题描述】:

在 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 有什么问题吗?

【问题讨论】:

标签: hibernate hibernate-mapping hibernate-4.x


【解决方案1】:
<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"/>

试试这个,应该会更好。

【讨论】:

  • 只需在 IntelliJ 中执行此操作://org/hibernate/hibernate-mapping-4.0.xsd
【解决方案2】:

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

【讨论】:

  • 谢谢,但目前有很多问题会触发 xsd 模式的使用。 Hibernate 开发团队将在下一个主要版本 5.0.0 中修复其中的一部分,因此目前无法迁移到此 xsd。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-18
  • 2011-11-28
  • 2012-05-29
  • 2010-11-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多