其他分享
首页 > 其他分享> > SpringBoot整合MyBatisPlus

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,SpringBoot,spring,BaseMapper,整合,mysql,com,id,starter
来源: https://www.cnblogs.com/WMZY/p/15870193.html