66 lines
2.1 KiB
Markdown
66 lines
2.1 KiB
Markdown
## 整合druid数据源
|
||
* 此处使用yml格式配置
|
||
```
|
||
spring:
|
||
profiles:
|
||
active: dev
|
||
|
||
datasource:
|
||
type: com.alibaba.druid.pool.DruidDataSource
|
||
druid:
|
||
url: jdbc:mysql://localhost:3306/springboot2Test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=UTC
|
||
username: root
|
||
password: xiaoyan159
|
||
# 连接池初始化连接数
|
||
initial-size: 5
|
||
# 连接不够时新增连接数
|
||
min-idle: 5
|
||
# 连接池最大连接数
|
||
max-active: 30
|
||
# 最大等待时间
|
||
max-wait: 30000
|
||
# 配置检测可以关闭的空闲连接间隔时间
|
||
time-between-eviction-runs-millis: 60000
|
||
# 配置连接在池中的最小生存时间
|
||
min-evictable-idle-time-millis: 300000
|
||
validation-query: select '1' from dual
|
||
test-while-idle: true
|
||
test-on-borrow: false
|
||
test-on-return: false
|
||
# 打开PSCache,并且指定每个连接上PSCache的大小
|
||
pool-prepared-statements: true
|
||
max-open-prepared-statements: 30
|
||
max-pool-prepared-statement-per-connection-size: 30
|
||
# 配置监控统计拦截的filters, 去掉后监控界面sql无法统计, 'wall'用于防火墙
|
||
filters: stat,wall
|
||
# Spring监控AOP切入点,如x.y.z.service.*,配置多个英文逗号分隔
|
||
aop-patterns: com.xiaoxiao.springboot2.servie.*
|
||
|
||
# WebStatFilter配置
|
||
web-stat-filter:
|
||
enabled: true
|
||
# 添加过滤规则
|
||
url-pattern: /*
|
||
# 忽略过滤的格式
|
||
exclusions: '*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*'
|
||
|
||
# StatViewServlet配置
|
||
stat-view-servlet:
|
||
enabled: true
|
||
# 访问路径为/druid时,跳转到StatViewServlet
|
||
url-pattern: /druid/*
|
||
# 是否能够重置数据
|
||
reset-enable: false
|
||
# 需要账号密码才能访问控制台
|
||
login-username: druid
|
||
login-password: druid123
|
||
# IP白名单
|
||
# allow: 127.0.0.1
|
||
# IP黑名单(共同存在时,deny优先于allow)
|
||
# deny: 192.168.1.218
|
||
|
||
# 配置StatFilter
|
||
filter:
|
||
stat:
|
||
log-slow-sql: true
|
||
``` |