springboot整合mybatis-plus

springboot整合mybatis-plus

1、版本说明
  • springboot: 2.3.0.RELEASE
  • mybatis-plus: 3.2.0
2、开始

导入对应依赖

<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <version>8.0.17version>
dependency>
<dependency>
    <groupId>com.baomidougroupId>
    <artifactId>mybatis-plus-boot-starterartifactId>
    <version>3.2.0version>
dependency>

注意:mysql-connector-java和依赖要和mysql启动的服务版本相对应。

官方说明:

https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-versions.html

写入配置项

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: xxxx
    password: xxxx
    url: jdbc:mysql://xxx.xxxx.xx.xx:3306/xxxx

mybatis-plus:
  # xml location
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      # config primary key auto-increment
      id-type: auto

启动类注释

@MapperScan("edu.virgil.mall.product.dao")

你可能感兴趣的:(主流框架详解,springboot,mybatis-plus整合)