错误信息::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" />
为什么找不到

解决方案 »

  1.   

    把错误的完整信息列出来,堆栈信息。你这个错误不一定是RootCause。另外可能出错的是Person.hbm.xml这个文件。错误是说无法解析,不是说找不到。
      

  2.   

    mapping映射文件解析错误。原因可以是:
    1、指定的name属性与bean中属性不一致
    2、指定column属性与table中字段不一致另外,mapping文件的指定有三种方式:
    1、用resource指定相对路径
    2、用file指定绝对路径
    3、用jar指定jar文件,
    建议使用相对路径,将mapping文件与hibernate.cfg.xml都放在src中即可。
      

  3.   

    Could not parse mapping document from resource com/hibernate/persistence/Person.hbm.xml
    是解析Person.hbm.xml的时候出错的,这个xml有问题,检查一下