Spring Boot下如何使用druid,给出个配置介绍吧,谢谢啦

s4n0splo  于 2021-11-27  发布在  Java
关注(0)|答案(3)|浏览(377)

plz

jxct1oxe

jxct1oxe1#

application properties

spring:
datasource:
name: testdb
url: jdbc:mysql://172.16.5.23:3306/vp_common_config?useUnicode=true&characterEncoding=utf-8
username: root
password: 'mQO7NpV1ohNjA37/xSIsNCIlVY4woR+zuAyeD3dBPpwcUX75gsZbvJftqhtpESDvItn6MUlJwrAAsi5+65fySQ=='

using druid data source

type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
maxActive: 20
initialSize: 1
maxWait: 28800
minIdle: 1
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 3000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: true
testOnReturn: false
poolPreparedStatements: true
maxOpenPreparedStatements: 20

encrypt password

filters: config,stat,wall,log4j
connectionProperties: "config.decrypt=true;druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000"
useGlobalDataSourceStat: true

data:
mongodb:
host: 172.16.45.3
port: 27017

redis:
database: 0
host: 172.16.45.3

password: 'traffic.prod'

port: 6379
timeout: 30000
pool:
  max-idle: 8
  min-idle: 0
  max-active: 8
  max-wait: -1
x33g5p2x

x33g5p2x2#

我使用springboot1.4.1,发现spring.datasource. filters无法被自动配置, 打开监控页面的数据源查看,发现filters一项为空。 如果我改成javaconfig方式,@bean一个DruidDataSource并且setFilters才成功使用stat等插件。另外initialSize、maxActive...这些参数也无法被springboot设置。请问问题出在那里?

8ftvxx2r

8ftvxx2r3#

spring boot 哪个版本 确定连接池那些配置会生效?

相关问题