s2sh整合遇到的问题Error creating bean with name

错误信息:

org.springframework.beans.factory.BeanCreationException:

Error creating bean with name 'departmentDao': Injection of resource fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name 'hibernateTemplate' defined in class path resource [spring/applicationContext-db.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is

 org.springframework.beans.factory.BeanCreationException: 

Error creating bean with name 'sessionFactory' defined in class path resource [spring/applicationContext-db.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: domain.User


不要只看到第一个Error creating bean with name 'departmentDao': 就认为是spring的xml配置的问题,其实最重要的是最后一句Association references unmapped class: domain.User。这里的问题是你的userbean的hibernate的配置问题,可能是你的配置文件里跟数据库中的字段不一样,,或者多对多、多对一的问题,都有可能。

你可能感兴趣的:(spring,Hibernate,数据库,bean,s2sh)