1、引入依赖的jar文件gav
1-1、druid可视化监控服务启动
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
1-2、数据源druid依赖jar文件gav引入
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.4</version>
<scope>compile</scope>
</dependency>
1-3、配置文件属性配置
spring:
datasource:
druid:
web-stat-filter:
exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico'
enabled: true
stat-view-servlet:
url-pattern: /druid/* #允许隐射的访问地址
login-username: admin #自定义druid可视化界面用户名
login-password: ******* #自定义druid可视化界面密码
enabled: true #是否开启druid可视化监控
max-active: 20
initial-size: 5
min-idle: 3
max-wait: 3000
time-between-eviction-runs-millis: 100000
filters: stat #druid可是化监控stat:监控统计、log4j:日志记录、wall:防御sql注入(SQL监控必选)
driver-class-name: com.mysql.cj.jdbc.Driver #连接数据库驱动
type: com.alibaba.druid.pool.DruidDataSource #指明数据源类型(默认是com.zaxxer.hikari.HikariDataSource)