import javax.persistence.Entity; 与import org.hibernate.annotations.Entity; 在Spring注解中

来源:互联网 发布:java企业级开发面试题 编辑:程序博客网 时间:2024/05/01 22:44

今天犯了一个错误。

在写实体类的时候@Entity注解Myeclipse将自动导为import org.hibernate.annotations.Entity; 

结果在测试的时候一直报这个实体类not Mapping  ,我就纠结了,

1、<property name="packagesToScan">
<value>com.xxx.model</value>
</property>

我写了,

2、<context:annotation-config/>Spring注解我也打开了

3、HQL语句是实体类名称不是表名


结果到处询问,一位大神告诉我将Entity包改成import javax.persistence.Entity;  ,因为import org.hibernate.annotations.Entity; 包不被Spring所识别,

问题解决了。


原创粉丝点击