本文使用druid连接池和mysql作为演示,springboot默认使用HikariCP连接池。
1、引入依赖
mysql mysql-connector-java8.0.26 log4j log4j1.2.12 com.alibaba druid1.2.8 org.mybatis.spring.boot mybatis-spring-boot-starter2.1.3
2、配置application.yml文件
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/mybatis?serverTimeZone=UTC&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: zhongxiaoting



