文章目录
SpringBoot整合Druid
1、创建项目Spring Initializr
2、选择技术及SQL(MyBatis、MySQL)
3、配置pom.xml导入druid的starter
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
4、配置数据库连接信息 application.yml
# 配置数据库连接
# 方法一
#spring:
# datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://localhost:3306/ssmbuild?serverTimezone=UTC
# username: root
# password: 111111
# type: com.alibaba.druid.pool.DruidDataSource
# 方法二
spring:
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ssmbuild?serverTimezone=UTC
username: root
password: 111111