Springboot 连接数据库配置
本文使用druid连接池和mysql作为演示,springboot默认使用HikariCP连接池。1、引入依赖<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.26</version&
·
本文使用druid连接池和mysql作为演示,springboot默认使用HikariCP连接池。
1、引入依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.26</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.8</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.3</version>
</dependency>
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
更多推荐
已为社区贡献3条内容
所有评论(0)