一:添加maven依赖
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>1.2.4</version>
</dependency>
二:新增tk 接口
@Repository
public interface TkMapper<T> extends Mapper<T>, MySqlMapper<T> {
}
三:在mapper层继承该接口,并加入实例bean
public interface AddressMapper extends TkMapper<Address> {
List<Address> selectListByIsDelete();
}
四:bean的话有一定的规则
如果bean中莫个字段不是表字段,可以使用 如下标签进行标识
@Transient
五:application.properties 新增配置
#jpa(tk) 配置
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=io.shulie.recruit.entity
mapper.mappers=io.shulie.recruit.common.mybatis.TkMapper
mapper.identity=MYSQL
六:结果展示,很多简单的CRURD 都不需要手写mapper啦
大功告成