MyBatisPlus快速入门——MyBatisPlus集成Druid配置应用

这里我重点讲一下如何使用mybatisplus与druid连接池进行整合,关于springboot整合mybatisplus可参考SpringBoot整合MyBatisPlus


要引入Druid数据库连接池,其实只需要在application.yml中配置相关的druid的数据即可

server:
  port: 8081

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: Sakura36!
    url: jdbc:mysql://localhost:3306/probe?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&llowMultiQueries=true
    type: com.alibaba.druid.pool.DruidDataSource
    druid:
      initial-size: 5
      min-idle: 5
      max-active: 20
      max-wait: 6000
      time-between-eviction-runs-millis: 60000
      min-evictable-idle-time-millis: 30000
      test-on-borrow: false
      test-on-return: false
      pool-prepared-statements: true
      max-pool-prepared-statement-per-connection-size: 20
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    map-underscore-to-camel-case: true # 开启驼峰命名转换:Table{create_time} -> Entity{createTime}
    use-generated-keys: true #使用jdbc的getGeneratedKeys获取数据库自增主键值

配置上述即可

你可能感兴趣的:(MyBatis,mybatis,druid)