首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Could not parse 地图ping document from resource

2012-10-21 
Could not parse mapping document from resource一直在找工作,也没有时间敲代码,今天闲下心来就写个hiber

Could not parse mapping document from resource
一直在找工作,也没有时间敲代码,今天闲下心来就写个hibernate的小程序,结果出现
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/entity/User.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:17)
at com.util.HibernateUtil.<clinit>(HibernateUtil.java:7)
at com.dao.UserDao.query(UserDao.java:12)
at com.dao.UserDao.main(UserDao.java:22)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/entity/User.hbm.xml
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4009)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3998)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3986)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at com.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:12)
... 3 more
Caused by: org.hibernate.MappingException: class com.entity.User.User not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:316)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:454)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:387)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:326)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:177)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4006)
... 8 more

找了好长时间 com/entity/User.hbm.xml 也看了就是看不出什么地方有问题  
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.entity.User">
    <class name="User" table="user">
       <id name="id" column="id">
            <generator column="name"/>
    </class>
</hibernate-mapping>

结果问题出在<class name="User" table="user">
把name=“User”改成com.entity.User 问题解决了

热点排行