springboot整合druid和配置资源监控
1.添加依赖,在maven repository中搜索
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.</version>
</dependency>
2.配置application.yml
spring:
datasource:
username: root
password: root
url: jdbc:mysql://localhost:3306
driver-class-name: com.mysql.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
initialSize: 5
maxActive: 10
maxWait: 3000
maxIdle: 8
minIdle: 3
3.整合druid数据源
@Configuration
public class DruidConfig {
@Bean
public DataSource druid(){
return new DruidDataSource();
}
//配置druid的监控
//1、配置一个管理后台的servlet
@Bean
public ServletRegistrationBean statViewServlet(){
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(),"druid/*");
Map<String,String> initParames = new HashMap<>();
initParames.put("loginUsername","admin");
initParames.put("loginPassword","123456");
initParames.put("allow","localhost");
bean.setInitParameters(initParames);
return bean;
}
//2、配置一个web监控的filter
@Bean
public FilterRegistrationBean webStatFilter(){
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new WebStatFilter());
Map<String,String> initParams = new HashMap<>();
initParams.put("exclusion","*.js,*.css,/druid/*");
bean.setInitParameters(initParams);
bean.setUrlPatterns(Arrays.asList("/*"));
return bean;
}
}
springboot整合druid和配置资源监控的更多相关文章
- 6_2.springboot2.x整合Druid和配置数据源监控
简介 Druid首先是一个数据库连接池.Druid是目前最好的数据库连接池,在功能.性能.扩展性方面,都超过其他数据库连接池,包括DBCP.C3P0.BoneCP.Proxool.JBoss Data ...
- springboot整合Druid(德鲁伊)配置多数据源数据库连接池
pom.xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-ja ...
- Springboot整合druid
目录 Springboot整合druid application.yml DruidConfig 数据监控地址:http://localhost:8080/druid Springboot整合drui ...
- SpringBoot整合Druid数据连接池
SpringBoot整合Druid数据连接池 Druid是什么? Druid是Alibaba开源的的数据库连接池.Druid能够提供强大的监控和扩展功能. 在哪里下载druid maven中央仓库: ...
- 【SpringBoot | Druid】SpringBoot整合Druid
SpringBoot整合Druid Druid是个十分强大的后端管理工具,具体的功能和用途请问阿里爸爸 1. 在pom.xml中导入包 <!-- alibaba 的druid数据库连接池 --& ...
- springboot整合druid、mybatis
目的: 1.springboot配置数据库连接池druid 测试druid中url监控 2.springboot整合mybatis 测试查删案例 3.springboot整合pagehelper sp ...
- SpringBoot整合Mybatis,TypeAliases配置失败的问题
SpringBoot整合Mybatis,TypeAliases配置失败的问题 问题描述 在应用MyBatis时,使用对象关系映射,将对象和Aliase映射起来. 在Mybatis的文档明确写出,如果你 ...
- SpringBoot系列七:SpringBoot 整合 MyBatis(配置 druid 数据源、配置 MyBatis、事务控制、druid 监控)
1.概念:SpringBoot 整合 MyBatis 2.背景 SpringBoot 得到最终效果是一个简化到极致的 WEB 开发,但是只要牵扯到 WEB 开发,就绝对不可能缺少数据层操作,所有的开发 ...
- springboot整合druid监控配置
方式一:直接引入druid 1.maven坐标 <dependency> <groupId>com.alibaba</groupId> <artifactId ...
随机推荐
- 洛谷P1832 A+B Problem(再升级) 题解 完全背包方案计数
题目链接:https://www.luogu.com.cn/problem/P1832 题目大意: 给定一个正整数n,求将其分解成若干个素数之和的方案总数. 解题思路: 首先找到所有 \(\le n\ ...
- 小小知识点(三十八)MPSK和MQAM调制的实现——利用IQ调制
IQ调制的原理 (一)调制基本原理 (二)调制基本原理 利用IQ调制实现MPSK(QPSK 8PSK BPSK)和MQAM(16QAM 64QAM)调制 (一)利用IQ调制实现QPSK调制 ...
- 一条SQL注入引出的惊天大案
前情回顾: WAF公司拦截到一个神秘的HTTP数据包,在这个包的表单字段中发现了SQL语句.目标指向80端口,而这正是nginx公司的地盘.详情参见:一个HTTP数据包的奇幻之旅 虚拟机的世界 一个安 ...
- Python 线性回归(Linear Regression) 基本理解
背景 学习 Linear Regression in Python – Real Python,对线性回归理论上的理解做个回顾,文章是前天读完,今天凭着记忆和理解写一遍,再回温更正. 线性回归(Lin ...
- Centos 中文乱码解决方法
问题描述 crontab -e 添加定时任务时,直接将下面内容粘贴过去,结果竟然乱码了. # 每个星期日凌晨3:00执行完全备份脚本 0 3 * * 0 /bin/bash -x /root/bash ...
- OpenStack Identity API v3
Table Of Contents OpenStack Identity API v3 What’s New in Version 3.7 What’s New in Version 3.6 What ...
- ATOM插件及快捷键
xml-formatter :https://atom.io/packages/xml-formatter xml格式化工具 SHIFT-CTRL-X:快速格式化 SHIFT-CTRL-M:移除换行符 ...
- 原生javascript实现二级延时菜单
一.实现原理: 使用定时器和排他思想完成 二.代码: <!DOCTYPE html> <html> <head> <title></title&g ...
- AD19覆铜与边框间距设置方法
转载请注明出处,并附带本文网址https://www.cnblogs.com/brianblog/p/9894867.html, 由于高版本AD不能将机械层直接转变为KEPP OUT LAYER层,所 ...
- kubernetes基础概念知多少
kubernetes(简称k8s)是一种用于在一组主机上运行和协同容器化应用程序的管理平台,皆在提供高可用.高扩展性和可预测性的方式来管理容器应用的生命周期.通过k8s,用户可以定义程序运行方式.部署 ...