错误信息::Could not parse mapping document from resource com/hibernate/persistence/Person.hbm.xml<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="show_sql">true</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/hibernate
</property>
<property name="connection.username">root</property>
<property name="connection.password">1234</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="com/hibernate/persistence/Person.hbm.xml" />
</session-factory></hibernate-configuration>
我明明写了
<mapping resource="com/hibernate/persistence/Person.hbm.xml" />
为什么找不到
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="show_sql">true</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/hibernate
</property>
<property name="connection.username">root</property>
<property name="connection.password">1234</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="com/hibernate/persistence/Person.hbm.xml" />
</session-factory></hibernate-configuration>
我明明写了
<mapping resource="com/hibernate/persistence/Person.hbm.xml" />
为什么找不到
1、指定的name属性与bean中属性不一致
2、指定column属性与table中字段不一致另外,mapping文件的指定有三种方式:
1、用resource指定相对路径
2、用file指定绝对路径
3、用jar指定jar文件,
建议使用相对路径,将mapping文件与hibernate.cfg.xml都放在src中即可。
是解析Person.hbm.xml的时候出错的,这个xml有问题,检查一下