在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出了什么问题吗?
发布于 2012-03-14 18:12:21
模式位置只是一个位置的标识符,这个位置可以绑定到任何地方: internet,本地驱动器。特别是,这个模式(以及hibernate-configuration-4.0.xsd)被放在org.hibernate包的hibernate-core jar中。因为通常schemaLocation和实际位置是相同的,所以集成开发环境会尝试从它指向的地方获取它,但这不是我们的情况。您可以将IDE配置为在此jar中查找此架构,以便可以使用自动完成功能。如果我们讨论的是IntelliJ,那么转到设置并配置您的模式和DTD以包括所需的模式。
发布于 2013-09-11 17:05:24
<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"/>试试这个,效果会更好。
https://stackoverflow.com/questions/8581634
复制相似问题