0
点赞
收藏
分享

微信扫一扫

spring整合mybatisPlus

小贴贴纸happy 2022-03-30 阅读 52


  1. 导入依赖

    <dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.0</version>
    </dependency>
  2. 配置

  1. 数据源配置

    spring:
    datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.85.128:3306/guli_pms?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
    driver-class-name: com.mysql.jdbc.Driver
  2. mybatisPlus配置

  1. 使用 @MapperScan 扫描接口层

    // 添加在启动类上
    @MapperScan("com.atguigu.gulimall.product.dao")
  2. 告诉MyBatis-Plus, sql映射文件的位置

    mybatis-plus:
    mapper-locations: classpath:/mapper/**/*.xml
  3. 配置主键自增

    mybatis-plus:
    mapper-locations: classpath:/mapper/**/*.xml
    global-config:
    db-config:
    id-type: auto


举报

相关推荐

0 条评论