SpringBoot对Druid配置SQL监控功能失效问题及解决方法
作者:JohnGea 时间:2023-06-10 21:31:24
由于我使用的是properties类型的配置文件,在对druid的参数进行配置的时候,多加了druid,也就是spring.datasource.druid.xxx,运行sql语句后SQL监控功能无效。
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/userinfo?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT
spring.datasource.username=root
spring.datasource.password=000214
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#连接池的配置信息
#初始化大小,最小,最大
spring.datasource.initialSize=5
#不再使用了,配置无效
#spring.datasource.minIdle=5
#最大连接池数量
spring.datasource.maxActive=20
# 配置获取连接等待超时的时间
spring.datasource.maxWait=60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
spring.datasource.timeBetweenEvictionRunsMillis=60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=SELECT 1 FROM DUAL
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
# 打开PSCache,并且指定每个连接上PSCache的大小
spring.datasource.poolPreparedStatements=true
spring.datasource.maxPoolPreparedStatementPerConnectionSize=20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
spring.datasource.filters=stat,wall,log4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
配置所有有关druid的配置多加了druid,导致sql监控无效,去掉就好了
不要这样配:spring.datasource.druid.xxx
没有使用yml配置,这里不知道为什么读取不到application.yml配置文件,倒是application.properties文件可以使用
来源:https://blog.csdn.net/qq_49451343/article/details/116602901
标签:SpringBoot,Druid,SQL,监控
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
C#的并发机制优秀在哪你知道么
2022-11-09 09:44:35
![](https://img.aspxhome.com/file/2023/1/116651_0s.png)
SpringMVC RESTFul及REST架构风格介绍
2021-09-30 05:05:33
![](https://img.aspxhome.com/file/2023/7/80917_0s.png)
Java多线程Thread基础学习
2023-04-17 17:12:21
![](https://img.aspxhome.com/file/2023/8/67688_0s.png)
IntelliJ IDEAx导出安卓(Android)apk文件图文教程
2022-06-22 18:26:16
![](https://img.aspxhome.com/file/2023/2/65802_0s.png)
Android自定义顶部标题栏
2023-02-21 19:03:47
![](https://img.aspxhome.com/file/2023/7/109167_0s.jpg)
解决Spring Cloud Feign 请求时附带请求头的问题
2022-12-11 04:29:46
C++与namespace有关的两个编译错误的讲解
2021-12-09 11:37:35
IDEA下Maven的pom文件导入依赖出现Auto build completed with errors的问题
2023-04-06 07:23:31
![](https://img.aspxhome.com/file/2023/9/129119_0s.jpg)
简单介绍java中equals以及==的用法
2023-01-28 07:47:41
![](https://img.aspxhome.com/file/2023/5/93145_0s.png)
分享我的第一次java Selenium自动化测试框架开发过程
2021-05-30 01:16:25
![](https://img.aspxhome.com/file/2023/5/66485_0s.png)
Java编写实现九宫格应用
2021-12-22 21:01:06
![](https://img.aspxhome.com/file/2023/5/125505_0s.jpg)
Java Swing 多线程加载图片(保证顺序一致)
2023-10-26 10:10:36
![](https://img.aspxhome.com/file/2023/0/65210_0s.jpg)
Spring boot @RequestBody数据传递过程详解
2022-09-14 12:23:37
![](https://img.aspxhome.com/file/2023/9/70359_0s.png)
Java中实现可拖放图片剪裁入门教程
2022-04-23 12:11:03
java实现压缩字符串和java字符串过滤
2023-01-06 10:35:19
SpringCloud用Zookeeper搭建配置中心的方法
2022-12-17 18:16:18
详解Spring ApplicationContext加载过程
2023-07-17 01:07:43
java编程之基于SpringBoot框架实现扫码登录
2023-02-14 02:39:28
![](https://img.aspxhome.com/file/2023/9/62999_0s.png)
C#实现移除字符串末尾指定字符的方法
2023-02-09 13:32:21
![](https://img.aspxhome.com/file/2023/8/102158_0s.png)
基于Flutter实现多边形和多角星组件
2023-06-19 06:02:50
![](https://img.aspxhome.com/file/2023/7/84747_0s.png)