最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
springboot整合druid及配置依赖代码示例
时间:2022-06-29 02:02:07 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下springboot整合druid及配置依赖代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
配置依赖
jdbc 依赖、数据库依赖(mysql),druid 依赖
com.alibaba druid-spring-boot-starter 1.1.17 org.springframework.boot spring-boot-starter-jdbc mysql mysql-connector-java
基本-配置信息
在 application.yaml 里
spring:
# 数据库
datasource:
url: jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8
username: root
password: root
做一个简单的查询,测试结果如图:
扩展-配置 druid 监控功能
在 spring-datasource 下
配置防火墙、监控页,开启web监控
spring:
# 数据库
datasource:
url: jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8
username: root
password: root
# druid 配置
druid:
# 配置监控防火墙功能
filters: stat,wall # 这两个详细参数可通过 filter-xxx 配置
filter:
stat:
enabled: true
slow-sql-millis: 1000 # 设置 1000ms 为慢查询
log-slow-sql: true # 开启慢查询监控
wall: # 在这里可配置 不允许更新、不允许删除等操作
enabled: true
# 开启监控页,并配置账号密码
stat-view-servlet:
enabled: true
login-username: admin
login-password: admin
# reset-enable: false # 重置按钮
# 开启web 监控功能。 urlPattern 和 exclusions 有默认值
web-stat-filter:
enabled: true
# aop-patterns: cc.acdongla.boot.* 配置监控包
启动项目后,http://l*ocalho**st:8080/druid/可进入 druid 的监控页
相关文章
- 漫蛙漫画官方入口-漫蛙漫画在线免费观看官网 10-27
- poki小游戏在线入口-poki免费游戏大全 10-27
- 豆包网页版入口官网-豆包官网网址入口 10-27
- 红果短剧官网在线入口-红果剧场高清网页版下载观看 10-27
- 剪映网页版登录-剪映官网入口直达 10-27
- 即梦官网网页版入口-即梦AI官方登录入口 10-27

