5
Druid监控sql无监控无数据怎么回事
source link: https://www.huhexian.com/45860.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
网上搜了很多,没有发现正确的解决方案,大部分抄来抄去,这里直接给新版Druid 的解决方案!
需要明确两个事情
- 新版Druid 可以不用写单独的配置类
- springboot
application.yam
文件中添加如下配置即可【在文章最后】 - 通过
http://localhost:8080/druid/login.html
登录到监控页面即可(用户名、密码都是配置文件中指定的root) - 成功之后数据源中的filter类名会显示如下,并且sql监控中也会有数据
application.yam
配置文件如下
spring:
datasource:
url: jdbc:mysql://127.0.0.1:13306/maicai
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
name: druid-999
initial-size: 5
min-idle: 5
max-active: 20
max-wait: 5000
# 状态监控
filter:
stat:
enabled: true
db-type: mysql
log-slow-sql: true
slow-sql-millis: 2000
# 监控过滤器
web-stat-filter:
enabled: true
exclusions:
- "*.js"
- "/druid/*"
# druid 监控页面
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
login-username: root
login-password: root
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK