我每次都会在第6行收到此xml错误。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.ida.hibernate">
<class name="Customer"table="customers"/>
<id name="cid"column="cid"type="int">
<genertor class="increment"/>
</id>
<property name="cname"column="cname"type="string"/>
<property name="email"column="email"type="string"/>
<property name="phone"column="phone"type="long"/>
<property name="city"column="city"type="string"/>
<property name="bal"column="bal"type="double"/>
</class>
</hibernate-mapping>
答案 0 :(得分:0)
<class name="Customer"table="customers"/>
==&gt;这相当于<class name="Customer"table="customers"></class>
替换为
<class name="Customer" table="customers">
在属性
之间添加空格您可以使用https://codebeautify.org/xmlvalidator或http://xmlbeautifier.com/等网站来验证和美化XML
<?xml version="1.0" encoding="UTF-8"?>
<hibernate-mapping package="com.ida.hibernate">
<class name="Customer" table="customers">
<id name="cid" column="cid" type="int">
<genertor class="increment" />
</id>
<property name="cname" column="cname" type="string" />
<property name="email" column="email" type="string" />
<property name="phone" column="phone" type="long" />
<property name="city" column="city" type="string" />
<property name="bal" column="bal" type="double" />
</class>
</hibernate-mapping>