gpt4 book ai didi

java - Intellij思想: Generate persistence mapping for Hibernate

转载 作者:太空宇宙 更新时间:2023-11-04 07:21:12 24 4
gpt4 key购买 nike

我正在尝试使用 Intellij 生成 Hibernate hbm.xml 文件,但在运行时遇到此问题:

ott 10, 2013 11:51:43 AM org.hibernate.internal.util.xml.ErrorLogger warning ERROR: HHH000198: Warning parsing XML (4) : schema_reference.4: lettura del documento di schema "http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd" non riuscita perché 1) non è stato possibile trovare il documento; 2) non è stato possibile leggere il documento; 3) l'elemento radice del documento non è <xsd:schema>.
...
ERROR: HHH000196: Error parsing XML (2) : cvc-elt.1: impossibile trovare la dichiarazione dell'elemento "hibernate-mapping".
Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML

生成的xml文件是这样的:

<?xml version='1.0' encoding='utf-8'?>
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<class name="it.blackcat.hibernatedemo3.hdao.Actor" table="actor" schema="" catalog="sakila">
<id name="actorId" column="actor_id"/>
<property name="firstName" column="first_name"/>
<property name="lastName" column="last_name"/>
<property name="lastUpdate" column="last_update"/>
</class>

知道 hibernate 映射有什么问题吗?谢谢!

编辑:

@LaGrandMere 解决了 DOCTYPE 的问题,但是...知道 Intellij 为何生成错误的 XML 吗?

最佳答案

你的

    xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd"

不太好。

尝试:

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

关于java - Intellij思想: Generate persistence mapping for Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19293123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com