spring - 配置服务器数据源连接@RefreshScope
问题描述
我有一个配置服务器和几个客户端。
这是我的配置设置:
@Component
@RefreshScope
@ConfigurationProperties(prefix = "params")
public class ConfigParams {
private Map<String, Map<String, String>> datasource;
// here are some other properties not related to db
}
我也有spring.cloud.refresh.extra-refreshable=javax.sql.DataSource
。因此,当更改某些配置参数时,将重新创建所有带有 @RefreshScope 的 bean(工作正常)。但即使数据源属性没有改变,与数据库的连接也会关闭和打开。那是糟糕的。
所以,我希望只有在相应的属性发生变化时才重新创建数据源 bean。不是每次。你能帮我吗?
我会很感激你的帮助。
解决方案
推荐阅读
- python-3.x - 如何在 Carvana 挑战中修复 Kaggle VGG16+U-Net 中的“ValueError:无法将字符串转换为浮点数:'eb91b1c659a0_12'”错误?
- shopify - 比较液体中的两个阵列 (Shopify)
- c - 使用 RDTSC 测量时间差 - 结果太大
- c# - 数据网格视图之外的标签未在数据网格行选定索引 ASP.NET 上更新
- css - 相对于视口的 SVG 背景图像
- assembly - 检查一个键是否被按下并读取它是哪个键的中断
- html - 如何判断给 img 一个固定的、始终可见的位置、填满屏幕并且没有溢出?(没有背景元素))
- google-chrome - 有没有办法在浏览器中缓存媒体文件?
- python - 如何使用多索引数据框绘制多个图形
- java - 使用此代码时 onclicklistener 不起作用