MybatisPlus entity XXX Not Found TableInfoCache.错误
- 首先需要当前的实体类继承 Model 并且指定当前的Model中的泛型为当前的实体类对象 其次还需要重写其中的pkVal方法
public class Student extends Model<Student> {
private int id;
private String name;
private String password;
private Double salary;
private int age;
protected Serializable pkVal() {
return id;
}
然后最重要的来了 如果是使用的Spring集成的MyBaitsPlus 需要使用ActiveRecord 必须 必须 必须 要先使用Spring 将当前的DAO接口 继承了BaseMapper 这个接口 创建出来,不然就会报错!!!恶心死了!!!!!
代码如图
StudentMapper sm = ac.getBean("studentMapper", StudentMapper.class);
Student st = new Student();
Student student = st.selectById(5);
System.out.println(student);