使用spring注解方式映射实体类,却报出class is not mapped
检查spring配置xml
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
确认是使用的AnnotationSessionFactoryBean注解方式的bean
再检查<property name="packagesToScan">,扫描包的包路径
我的class类在com.ssh.entity下,因此包路径设置的是com.ssh.entity
反复查阅资料后发现,这个包路径不能设置成当前包路径,而是要设置成当前包的上层
也就是应该设置为
<property name="packagesToScan">
<list>
<value>com.ssh.*</value>
</list>
</property>
问题解决