spring-boot - How to using annotation @RefreshScope with spingboot : connectionFactory?
问题描述
how to refresh connectionFactory
or connectionpool
,such as dataSource
,JedisConnectionFactory
... when the springboot application is running?
(I used springcould-config to update my configs)
@Bean
@ConfigurationProperties(prefix = "spring.redis.pool")
public JedisPoolConfig getRedisConfig() {
JedisPoolConfig config = new JedisPoolConfig();
return config;
}
@Bean(name = "redisConnection")
public JedisConnectionFactory getConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
JedisPoolConfig config = getRedisConfig();
factory.setPoolConfig(config);
factory.setPassword(password);
factory.setHostName(hostName);
factory.setPort(port);
factory.setDatabase(database);
return factory;
}
...
pseudocode:
onChangeListener function then
refreshScope.refresh("redisConnection");
but it does not work,however, some files with @Value("${spring.redis.host}")
it change
解决方案
推荐阅读
- mysql - 在 SQL 查询结果中使用格式 DE_DE 和无限小数位
- odoo - 如何停止 Qweb 调用计算域的计算方法以在 odoo9 中生成结果?
- go - 在 golang jwt-go 中解码 JWT
- azure - Azure API 管理 - 开发门户:在操作视图上显示产品级别策略?
- google-bigquery - 将 DoubleClick Search 报告的 BigQuery 传输到 BigQuery
- mysql - MYSQL 使用外键对现有表进行分区
- javascript - 传递给 forEach 回调的 f 和 i 参数是什么?
- linux - Alsa 项目使用具有大量内存泄漏信息的 MTrace
- vba - 循环中的 VBA 复制和粘贴
- docker - 将 postgres 端口转发到 docker-toolbox 的容器中