1.Spring Boot 集成通用Mapper
<!--引入mybatis启动器-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
<!--添加通用mapper组件-->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.4</version>
</dependency>
2.编写配置文件
#mapper
#mappers 多个接口时逗号隔开
mapper.mappers=tk.mybatis.mapper.common.Mapper
#insert和update中,是否判断字符串类型!=''
mapper.not-empty=false
#使用的数据库语言,通用mapper可以操作多种数据库
mapper.identity=MYSQL
3.编写接口继承Mapper接口操作即可
//User为自定义和数据库表对应的对象
interface UserMapper extends Mapper<User>,MySqlMapper<User>{
}
4.Mapper,MySqlMapper方法详解
1.MySqlMapper方法详解
2.Mapper方法详解:Mapper继承BaseMapper及ExampleMapper
①BaseMapper
②ExampleMapper