Springboot 实现Redis 同数据源动态切换db
public void setDataBase(int num) { LettuceConnectionFactory connectionFactory = (LettuceConnectionFactory) redisTemplate.getConnectionFactory(); if (connectionFactory != null && num != connectionFactory.getDatabase()) { connectionFactory.setDatabase(num); this.redisTemplate.setConnectionFactory(connectionFactory); connectionFactory.resetConnection(); } }
参考:https://developer.aliyun.com/article/952648
###########################
QQ 3087438119