问题描述
照网上方法,试了很多,但仍解决不了。=========================================================================================================12:01:14,672 INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}12:01:14,721 INFO Version:41 - HHH000412: Hibernate Core {4.1.10.Final}12:01:14,731 INFO Environment:239 - HHH000206: hibernate.properties not found12:01:14,734 INFO Environment:342 - HHH000021: Bytecode provider name : javassist12:01:14,783 INFO Configuration:1926 - HHH000043: Configuring from resource: /hibernate.cfg.xml12:01:14,784 INFO Configuration:1945 - HHH000040: Configuration resource: /hibernate.cfg.xml12:01:15,199 INFO Configuration:718 - HHH000221: Reading mappings from resource: cn/jhost/alibaba/user/vo/UserModel.hbm.xml12:01:15,522 INFO Configuration:2067 - HHH000041: Configured SessionFactory: nullorg.hibernate.InvalidMappingException: Could not parse mapping document from resource cn/jhost/alibaba/user/vo/UserModel.hbm.xmlat org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3423)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3412)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3400)at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1330)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1730)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781)at cn.jhost.alibaba.common.HibernateUtil.<clinit>(HibernateUtil.java:13)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModelat org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:182)at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:174)at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:197)at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:253)at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:324)at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2311)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2276)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2166)at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:407)at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:322)at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:173)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3420)... 11 moreException in thread "main" java.lang.NullPointerExceptionat cn.jhost.alibaba.common.HibernateUtil.currentSession(HibernateUtil.java:26)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)===============================================================================================<?xml version="1.0" encoding='utf-8'?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="cn.jhost.alibaba.user.vo.UserModel" table="tbl_user" dynamic-insert="true" dynamic-update="true" optimistic-lock="version"> <id name="uuid"> <generator class="uuid"/> </id> <version name="version" column="version"/> <property name="name" column="name" /> <property name="password" column="password"/><property name="type" column="type"/> </class> </hibernate-mapping>====================================================================================<?xml version='1.0' encoding='utf-8'?><!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/alibaba?useUnicode=true&characterEncoding=UTF-8</property> <property name="connection.username">root</property> <property name="connection.password">123456</property> <property name="c3p0.min_size">5</property> <property name="c3p0.max_size">20</property> <property name="c3p0.timeout">180</property> <property name="c3p0.max_statements">5</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <property name="show_sql">true</property><property name="format_sql">true</property> <mapping resource="cn/jhost/alibaba/user/vo/UserModel.hbm.xml"/> </session-factory> </hibernate-configuration>
解决方案
org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModel你的cn.jhost.alibaba.user.vo.UserModel 里边有 password属性吗? 贴下看看
解决方案二:
错误不是很明显了么?Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModelcn.jhost.alibaba.user.vo.UserModel这个类中没有password属性,而你的配置文件中确有这个字段,检查一下吧。