Springboot整合druid
Springboot整合druid
application.yml
# 此处用来配置数据库
spring:
datasource:
url: jdbc:mysql://192.168.0.169:3306/jpa
username: root
password: xiaoyan
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
# 下面为连接池的补充设置,应用到上面所有数据源中, 可以写, 可以不写
# 初始化大小,最小,最大
initialSize: 5
minIdle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
DruidConfig
@Configuration
public class DruidConfig {
@ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DataSource druid() {
return new DruidDataSource();
}
@Bean
public ServletRegistrationBean<StatViewServlet> statViewServlet() {
ServletRegistrationBean<StatViewServlet> registrationBean = new ServletRegistrationBean<>();
registrationBean.setServlet(new StatViewServlet());
registrationBean.setUrlMappings(Collections.singletonList("/druid/*"));
//设置初始化参数
Map<String, String> initMap = new HashMap<>();
// 登录账户密码
initMap.put("loginUsername", "admin");
initMap.put("loginPassword", "123456");
initMap.put("allow", "");
initMap.put("deny", "");
registrationBean.setInitParameters(initMap);
return registrationBean;
}
@Bean
public FilterRegistrationBean<WebStatFilter> webStatFilter() {
FilterRegistrationBean<WebStatFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new WebStatFilter());
registrationBean.setUrlPatterns(Collections.singletonList("/*"));
//设置初始化参数
Map<String, String> initMap = new HashMap<>(1);
initMap.put("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
registrationBean.setInitParameters(initMap);
return registrationBean;
}
}
数据监控地址:http://localhost:8080/druid
Springboot整合druid的更多相关文章
- 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整合druid和配置资源监控
1.添加依赖,在maven repository中搜索 <dependency> <groupId>com.alibaba</groupId> <artifa ...
- springboot整合druid连接池、mybatis实现多数据源动态切换
demo环境: JDK 1.8 ,Spring boot 1.5.14 一 整合durid 1.添加druid连接池maven依赖 <dependency> <groupId> ...
- 【SpringBoot笔记】SpringBoot整合Druid数据连接池
废话少说,按SpringBoot的老套路来. [step1]:添加依赖 <!-- 数据库连接池 --> <dependency> <groupId>com.alib ...
- SpringBoot整合Druid数据源
关于SpringBoot数据源请参考我上一篇文章:https://www.cnblogs.com/yueshutong/p/9409295.html 一:Druid介绍 1. Druid是什么? Dr ...
- SpringBoot整合Druid(阿里巴巴)数据源
(1).添加相关依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId ...
- springboot整合druid数据库连接池并开启监控
简介 Druid是一个关系型数据库连接池,它是阿里巴巴的一个开源项目.Druid支持所有JDBC兼容的数据库,包括Oracle.MySQL.Derby.PostgreSQL.SQL Server.H2 ...
随机推荐
- Floyd(求每2个点之间的最短路)
稍微改变即可求传递闭包,即关心两点之间是否有同路: for(int i=0;i<n;i++) for(int j=0;j<n;j++){ if(i==j) d[i][i]=0; else ...
- Classloader精简重点
如果想学习classloader的具体内容,请goodu JVM 在运行时会产生三个ClassLoader,Bootstrap ClassLoader.Extension ClassLoader和 A ...
- 使用数据泵expdp、impdp备份和还原oracle数据库
前面我已经整理过EXP 和 IMP备份和还原Oracle数据库的方法 今天我们只讲使用数据泵 expdp 和impdp的方法,有的同学会问他们有什么差别呢? EXP和IMP是客户端工具程序,它们既可以 ...
- 学习笔记TF067:TensorFlow Serving、Flod、计算加速,机器学习评测体系,公开数据集
TensorFlow Serving https://tensorflow.github.io/serving/ . 生产环境灵活.高性能机器学习模型服务系统.适合基于实际数据大规模运行,产生多个模型 ...
- Google - Find minimum number of coins that make a given value
Given a value V, if we want to make change for V cents, and we have infinite supply of each of C = { ...
- 常识判断-科技-day123
PS: 在常识中科技是最难的 PS: 20-2w HZ是人能听到的频率 PS: 物体的熔点和凝固点是一致的 PS: 氮肥如果多了,可能只是长叶子不结果: 磷肥促进开花结果 PS; 病毒是介于生物和非 ...
- Git自动化合并多个Commit
目录 git rebase逻辑 git editor的修改 处理git-rebase-todo文件 Python实现 当我们有多个commit或者从开源处拿到多个commit时,想合成一个commit ...
- DOM 基础
文档对象模型(Document Object Model)是表示和处理一个HTML或XML文档的常用方法 查找 直接查找 var obj = document.getElementById('i1') ...
- python 基础之变量存储缓存机制与数据驻留小数据池
一:变量存储的缓存机制 在同一文件(模块)里,变量存储的缓存机制 (仅对python3.x版本负责),那么 --对于Number (int bool float complex) 1.对于整型而言,- ...
- log4j-over-slf4j和slf4j-log4j12冲突问题解决
解决办法: 两个jar包会循环引用导致内存溢出.解决的办法就是将两个jar包其中一个的依赖移除掉