0

Druid监控sql无监控无数据怎么回事

 4 months ago
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 的解决方案!

需要明确两个事情

  1. 新版Druid 可以不用写单独的配置类
  2. springboot application.yam文件中添加如下配置即可【在文章最后】
  3. 通过 http://localhost:8080/druid/login.html 登录到监控页面即可(用户名、密码都是配置文件中指定的root)
  4. 成功之后数据源中的filter类名会显示如下,并且sql监控中也会有数据
    Druid监控sql无监控无数据怎么回事
    Druid监控sql无监控无数据怎么回事

application.yam 配置文件如下

  1. spring:
  2. datasource:
  3. url: jdbc:mysql://127.0.0.1:13306/maicai
  4. username: root
  5. password: root
  6. driver-class-name: com.mysql.cj.jdbc.Driver
  7. druid:
  8. name: druid-999
  9. initial-size: 5
  10. min-idle: 5
  11. max-active: 20
  12. max-wait: 5000
  13. # 状态监控
  14. filter:
  15. stat:
  16. enabled: true
  17. db-type: mysql
  18. log-slow-sql: true
  19. slow-sql-millis: 2000
  20. # 监控过滤器
  21. web-stat-filter:
  22. enabled: true
  23. exclusions:
  24. - "*.js"
  25. - "/druid/*"
  26. # druid 监控页面
  27. stat-view-servlet:
  28. enabled: true
  29. url-pattern: /druid/*
  30. reset-enable: false
  31. login-username: root
  32. login-password: root

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK