昨天做一个项目,配置好了java类和对应的hbm.xml文件,自动生成数据库表时候报以下错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Association references unmapped class: Comment
在网上找了一些资料现在吧解决办法整理如下:
1、先要检查java类与hbm中的基本属性是否对应
2、要检查java类与hbm中的关联属性是否对应,关联属性中的外键配置是否一致
问题一般出现在以上两种情况,由于马虎大意
3、还是不可以的话,要把hbm中关联属性中的class加上全称,即 包+文件名