版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wangfei0904306/article/details/78936488
Druid作为一个优秀的数据库连接池,国内几乎大小项目都会用,最近项目中涉及新旧系统并用,老的Oracle性能不稳,这时候的监控就非常必要且急需了。下面说一下Druid打开监控的步骤:
1. application.yml配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=true
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver #非必需
type: com.alibaba.druid.pool.DruidDataSource #非必需
druid:
initialSize: 2
minIdle: 2
maxActive: 30
######Druid监控配置######
WebStatFilter:
exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
StatViewServlet:
loginUsername: druid
loginPassword: druid
2. 在这个模块的POM下添加依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
3. 启动项目,打开:localhost:8080/druid/login.html 输入用户名和密码 druid/druid
Git项目简单范例:https://github.com/wangfei0904306/druidMonitorTest
更加详细的介绍请参考:https://github.com/alibaba/druid