Druid是阿里巴巴开源平台上一个数据库连接池实现,它结合了C3P0、DBCP、PROXOOL等DB池的优点,同时加入了日志监控,可以很好的监控DB池连接和SQL的执行情况,可以说是针对监控而生的DB连接池(据说是目前最好的连接池)。今天主要讲在SpringBoot2.0中集成Druid。

在springboot2.0中,几乎不用修改任何代码,只需要引入pom.xml,更新application.properties即可轻松完成Druid的搭建。

v修改pom.xml

        <dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.1.9</version></dependency>

v目录结构

v更新application.properties

# Druid连接池配置,官方配置参考:https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter
# spring.datasource的相关配置在application-dev.properties中,所以这里直接注释了
#spring.datasource.druid.url=jdbc:mysql://10.168.0.24:3306/dmp_db?useUnicode=true&characterEncoding=utf8
#spring.datasource.druid.username=root
#spring.datasource.druid.password=123456
spring.datasource.druid.initial-size=5
spring.datasource.druid.max-active=20
spring.datasource.druid.min-idle=10
spring.datasource.druid.max-wait=10
spring.datasource.druid.filters=stat,wall
spring.datasource.druid.filter.stat.log-slow-sql=true
spring.datasource.druid.filter.stat.slow-sql-millis=2000# Druid WebStatFilter配置,说明请参考Druid Wiki,配置_配置WebStatFilter
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-stat-filter.exclusions=*.gif,*.png,*.jpg,*.html,*.js,*.css,*.ico,/druid/*# Druid StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
spring.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
spring.datasource.druid.stat-view-servlet.reset-enable=true
spring.datasource.druid.stat-view-servlet.login-username=admin
spring.datasource.druid.stat-view-servlet.login-password=admin
spring.datasource.druid.stat-view-servlet.allow=
spring.datasource.druid.stat-view-servlet.deny=# Redis配置,官方参考:https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#common-application-properties
#spring.redis.database=0
#spring.redis.host=127.0.0.1
#spring.redis.port=6379
#spring.redis.password=
#spring.redis.timeout=5000

v效果图

作  者:请叫我头头哥
出  处:http://www.cnblogs.com/toutou/
关于作者:专注于基础平台的项目开发。如有问题或建议,请多多赐教!
版权声明:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。
特此声明:所有评论和私信都会在第一时间回复。也欢迎园子的大大们指正错误,共同进步。或者直接私信我
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是作者坚持原创和持续写作的最大动力!

转载于:https://www.cnblogs.com/toutou/p/9907354.html

SpringBoot入门教程(十五)集成Druid相关推荐

  1. SpringBoot入门教程(十)应用监控Actuator

    Actuator可能大家非常熟悉,它是springboot提供对应用自身监控,以及对应用系统配置查看等功能.spring-boot-starter-actuator模块的实现对于实施微服务的中小团队来 ...

  2. 【QT】QT从零入门教程(十五):QImage和Mat的转换

      QT处理图像用的是QImage类,而OpenCV处理图像则是使用cv::Mat类,如果要在QT中运用OpenCV,那就需要进行QImage和Mat的相互转换. // cv::Mat转换成QImag ...

  3. ExtJs 入门教程十五[列模型 :ColumnModel]

    一.效果 二.代码 var fwzcm= new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),new Ext.grid.CheckboxSelec ...

  4. SpringBoot入门教程(转)

    SpringBoot入门教程 注:此文章转载于GitHub,但是原文章图片加载出错,因此我整理了一下,并非本人原创,在此感谢原作者! 附上原文视频课地址供大家学习: www.bilibili.com/ ...

  5. springboot 入门教程(4)--web开发(spring mvc和Thymeleaf模板,带源码)

    2019独角兽企业重金招聘Python工程师标准>>> 首先回顾下前几篇的内容:springboot 入门教程(1),springboot 入门教程-Thymeleaf(2), sp ...

  6. Photoshop入门教程(五):滤镜

    学习心得:滤镜通常用于摄影行业,是安装在相机镜头前用于过滤自然光的附加镜头,从而获得一些特殊的效果.同理,Photoshop的滤镜也是为了产生特殊的效果.Photoshop滤镜分为两类:一种是内部滤镜 ...

  7. SpringBoot入门教程

    SpringBoot入门教程 1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案. 2.微服务 微服务:架构风格 ...

  8. 【STM32】HAL库 STM32CubeMX教程十五---FMC-SDRAM(二)

    前言: 本系列教程将HAL库与STM32CubeMX结合在一起讲解,使您可以更快速的学会各个模块的使用 上一讲我们说了CubeMX配置SDRAM的一些基本配置,还有FMC跟SDRAM的讲解,这一讲我们 ...

  9. 【STM32】HAL库 STM32CubeMX教程十五---FMC-SDRAM(一)

    前言: 本系列教程将HAL库与STM32CubeMX结合在一起讲解,使您可以更快速的学会各个模块的使用 本文 1首先讲解什么是FMC及SDRAM,W9825G6KH芯片原理,2基于CubeMx创建工程 ...

最新文章

  1. SAP PI 7.3新特性介绍
  2. 禁止服务器的协议,Windows 服务器禁用 SSL 2 和 SSL 3 协议
  3. Postfix+dovecot+extmail+sasl+mysql源码安装手册
  4. entity、model和domain三者区别
  5. Linux 系统如何查看硬盘UUID与修改
  6. Google Maps API 调用实例
  7. Linux的环境中如何生成srw-rw---- 的文件权限?
  8. C++之new再探究
  9. 根据线程名获取线程及停止线程
  10. 域内计算机策略应用顺序
  11. Oracle中的用户创建和权限的分配
  12. Oracle PL/SQL 程序设计读书笔记 - 第13章 其他数据类型
  13. 同步现象 心理学_「心理学学了些什么?」基础心理学知识1
  14. EDI的含义及其重要性
  15. android写轮眼,打造iOS般流畅的安卓 神器写轮眼使用教程
  16. 如何安装M26F1 5G路由器
  17. ESP8266红外学习遥控器
  18. 【Windows、Git问题】detected dubious ownership in repository 问题解决
  19. 转载一个特征提取的方法——AE
  20. 英格兰的政治+德意志的工业科技+犹太的金融+北美的丰富资源=世界NO.1强国

热门文章

  1. 【收藏】使用命令行创建maven web项目
  2. Spark on Yarn集群多Application并行执行
  3. arthas使用示例:trace追踪方法调用路径及统计方法耗时
  4. Python爬虫开发:cookie的使用案例
  5. Hystrix配置参数查找方式
  6. 请你简单介绍一下ArrayList和LinkedList的区别及大数据量情况下的插入效率对比
  7. MySQL列转行sql语句
  8. 由于更换了java版本,Eclipse启动时报错:JRE or JDK must be available in order to run Eclipse
  9. 第一行代码学习笔记第五章——详解广播机制
  10. C++面向对象设计原则详解