Java SpringBoot Druid

1、引入依赖

  1. <dependency>
  2. <groupId>com.alibaba</groupId>
  3. <artifactId>druid-spring-boot-starter</artifactId>
  4. <version>1.1.13</version>
  5. </dependency>

2、YAML配置

  1. spring:
  2. datasource:
  3. driverClassName: com.mysql.cj.jdbc.Driver
  4. type: com.alibaba.druid.pool.DruidDataSource
  5. druid: # #
  6. url: ${mysql.url}?${jdbcUrlArgs}
  7. username: ${mysql.username}
  8. password: ${mysql.password}
  9. initial-size: 10
  10. max-active: 200
  11. min-idle: 10
  12. max-wait: 60000
  13. pool-prepared-statements: false
  14. validation-query: SELECT 1 FROM DUAL
  15. test-on-borrow: false
  16. test-on-return: false
  17. test-while-idle: true
  18. time-between-eviction-runs-millis: 60000
  19. min-evictable-idle-time-millis: 30000
  20. max-pool-prepared-statement-per-connection-size: 20
  21. aop-patterns: com.msyyt.crm.activity.*
  22. filter: # 状态监控
  23. stat:
  24. enabled: true
  25. db-type: mysql
  26. log-slow-sql: true
  27. slow-sql-millis: 2000
  28. web-stat-filter: # 监控过滤器
  29. enabled: true #是否启用 默认true
  30. exclusions:
  31. - '*.js'
  32. - '*.gif'
  33. - '*.jpg'
  34. - '*.png'
  35. - '*.css'
  36. - '*.ico'
  37. - /druid/*
  38. stat-view-servlet: # druid 监控页面
  39. enabled: true
  40. url-pattern: /druid/*
  41. reset-enable: false
  42. allow: # 白名单
  43. deny: # 黑名单
  44. login-username: admin
  45. login-password: admin