[ MybatisPlus ] (一)SpringBoot 整合 MybatisPlus

SpringBoot 整合 MybatisPlus


1.导入依赖

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

2.编辑配置文件

  • application.yml
# 连接mysql数据库
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/mp?useSSL=false&serverTimezone=GMT%2B8
    username: root
    password: 123456
#设置日志输出级别
logging:
  level:
    root: warn
    cust.aowei.mybatisplus.mapper: trace
  pattern:
    console: '%p%m%n'

3.编辑 mapper

  • 继承 BaseMapper
public interface UserMapper  extends BaseMapper<User> {
}

4.修改启动类

  • 添加注解
  • 扫描mapper所在包
@MapperScan("cust.aowei.mybatisplus.mapper")

在这里插入图片描述

发布了132 篇原创文章 · 获赞 1246 · 访问量 30万+

猜你喜欢

转载自blog.csdn.net/qq_43901693/article/details/104376612