SpringBoot整合MyBatisPlus

1.导入mybatisplus与Druid对应的starter

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.6</version>
</dependency>

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

2.配置数据源与MyBatisPlus对应的基础配置

spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybaits?serverTimezone=UTC
username: root
password: root

mybatis-plus:
global-config:
db-config:
table-prefix: tbl_
#id生成策略使用数据库策略
id-type: auto

3配置数据层的接口继承BaseMapper并指定泛型

@Mapper
public interface BookDao extends BaseMapper<Book> {

}

  

 

上一篇:mybatisplus-代码级别的自动生成创建丶更新时间


下一篇:MybatisPlus二级缓存