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