超容易的druid连接池的使用配置、监控页面配置

发现druid连接池的监控页面使用感良好,虽然之前写的博客有简单介绍过,但还是写一篇博客详细记录一下druid连接池的使用配置、监控页面的配置,包括自己遇到的一些坑。

超容易的druid连接池的使用配置、监控页面配置

1、druid连接池简单介绍(官网)

  druid,翻译过来就是德鲁伊的意思。druid连接池是阿里巴巴开发的一款非常好用的连接池,它支持目前流行的几款数据库,如MySQL、SQLServer、Oracle、SQLite等等。而且它提供了很好的监控的功能,可以监控SQL的使用、Session的读取、以及路径的读取和Spring的监控等等,可以说是功能强大了。
  这是druid连接池的官网地址,有兴趣的朋友可以上去看看。
  下图是目前支持的所有数据库:
在这里插入图片描述
  一些常用数据库的驱动名称:
在这里插入图片描述
在这里插入图片描述

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在项目中使用Spring Boot配置Druid连接池需要以下步骤: 1. 在pom.xml文件中添加Druid的依赖: ``` <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.22</version> </dependency> ``` 2. 在application.properties或application.yml文件中配置Druid连接池的相关属性,如url、username、password等。 ``` spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.type=com.alibaba.druid.pool.DruidDataSource ``` 3. 在启动类中添加@ServletComponentScan注解,开启Druid的StatViewServlet和WebStatFilter: ``` @ServletComponentScan @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ``` 4. 在application.properties或application.yml中配置Druid的StatViewServlet和WebStatFilter: ``` # Druid配置 spring.datasource.druid.stat-view-servlet.enabled=true spring.datasource.druid.stat-view-servlet.url-pattern=/druid/* spring.datasource.druid.web-stat-filter.enabled=true spring.datasource.druid.web-stat-filter.url-pattern=/druid/* ``` 5. 启动项目后,访问http://localhost:端口/druid/index.html即可看到Druid监控页面。 需要注意的是,上面只是最基本的配置Druid还有很多高级功能,可以根据需要进行配置
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值