使用mybatis-plus版本为 3.1.0,springboot版本为2.2.4.RELEASE
- 实体类继承Model 泛型为该实体类 ,泛型一定要写,我就是因为这个报错
@Data
@TableName("t_user_expand")
@KeySequence(value = "t_user_expand_id_seq")
@EqualsAndHashCode(callSuper = false)
public class UserExpand extends Model<UserExpand> {...}
- 重写Model类的pkVal()方法,return当前类的主键
@Override
protected Serializable pkVal() {
return id;
}
- 实体类需要有对应的Mapper 并且该Mapper继承BaseMapper 泛型为该实体类
public interface UserExpandMapper extends BaseMapper <UserExpand>{...}