Mybatis通用Mapper使用

通用Mapper:为了解决单表增删改查,基于Mybatis的插件。开发人员不需要编写SQL,不需要在DAO中增加方法,Mybatis无需生成基础mapper.xml,只要写好实体类,就能支持相应的增删改查方法。

tk.mybatis通用依赖

<dependency>
    <groupId>tk.mybatis</groupId>
    <artifactId>mapper-spring-boot-starter</artifactId>
    <version>2.0.0</version>
</dependency>

在dao中直接继承Mapper即可

import cn.test.pojo.ApplyOperateRecord;
import tk.mybatis.mapper.common.Mapper;
public interface ApplyOperateRecordMapper extends Mapper<ApplyOperateRecord> {
}

详细可参考https://www.cnblogs.com/mzywucai/p/11053360.html

或者使用Mybatis Plus依赖

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>Latest Version</version>
</dependency>

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.3.1.tmp</version>
</dependency>

继承BaseMapper

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.test.ftd.entity.Resume;
public interface ResumeMapper extends BaseMapper<Resume>{
}