pom.xml
<!-- Druid 数据库连接池 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.23</version></dependency>
application.yml
spring:jackson:date-format: yyyy-MM-dd HH:mm:sstime-zone: GMT+8datasource:type: com.alibaba.druid.pool.DruidDataSourcedriver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/spring_boot_demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghaiusername: rootpassword: 123456druid:initial-size: 5min-idle: 1max-wait: 60000stat-view-servlet:# 可视化页面enabled: true# 可视化界面用户名login-username: admin# 可视化界面密码login-password: admin# 可视化界面地址前缀url-pattern: "/druid/*"web-stat-filter:enabled: trueurl-pattern: "/*"exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*"filter:stat:enabled: true# 数据库类型db-type: mysql# 记录慢SQLlog-slow-sql: true# 默认慢SQL为500ms,这里改成2msslow-sql-millis: 2
启动并执行一条SQL后打开监控页面
8080是你的SpringBoot项目端口
http://localhost:8080/druid/index.html
执行一条SQL
打开SQL监控页面查看慢SQL