mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
redis配置修正:单机、哨兵、集群
This commit is contained in:
+9
-24
@@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import com.cf.imes.framework.common.util.encrypt.AesUtils;
|
import com.cf.imes.framework.common.util.encrypt.AesUtils;
|
||||||
import org.redisson.config.ClusterServersConfig;
|
import org.redisson.config.ClusterServersConfig;
|
||||||
import org.redisson.config.Config;
|
import org.redisson.config.Config;
|
||||||
import org.redisson.config.MasterSlaveServersConfig;
|
|
||||||
import org.redisson.config.ReplicatedServersConfig;
|
|
||||||
import org.redisson.config.SentinelServersConfig;
|
import org.redisson.config.SentinelServersConfig;
|
||||||
import org.redisson.config.SingleServerConfig;
|
import org.redisson.config.SingleServerConfig;
|
||||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||||
@@ -33,44 +31,31 @@ public class ChenfengRedisEncryptAutoConfiguration {
|
|||||||
BeanUtil.copyProperties(configuration, redissonConfig);
|
BeanUtil.copyProperties(configuration, redissonConfig);
|
||||||
|
|
||||||
String password;
|
String password;
|
||||||
SingleServerConfig singleServerConfig = redissonConfig.useSingleServer();
|
|
||||||
if (singleServerConfig != null) {
|
|
||||||
|
|
||||||
|
// 单机模式
|
||||||
|
if (redissonConfig.isSingleConfig()) {
|
||||||
|
SingleServerConfig singleServerConfig = redissonConfig.useSingleServer();
|
||||||
password = singleServerConfig.getPassword();
|
password = singleServerConfig.getPassword();
|
||||||
singleServerConfig.setPassword(
|
singleServerConfig.setPassword(
|
||||||
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MasterSlaveServersConfig masterSlaveServersConfig = redissonConfig.useMasterSlaveServers();
|
// 哨兵模式
|
||||||
if (masterSlaveServersConfig != null) {
|
if (redissonConfig.isSentinelConfig()) {
|
||||||
password = masterSlaveServersConfig.getPassword();
|
SentinelServersConfig sentinelServersConfig = redissonConfig.useSentinelServers();
|
||||||
masterSlaveServersConfig.setPassword(
|
|
||||||
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SentinelServersConfig sentinelServersConfig = redissonConfig.useSentinelServers();
|
|
||||||
if (sentinelServersConfig != null) {
|
|
||||||
password = sentinelServersConfig.getPassword();
|
password = sentinelServersConfig.getPassword();
|
||||||
sentinelServersConfig.setPassword(
|
sentinelServersConfig.setPassword(
|
||||||
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClusterServersConfig clusterServersConfig = redissonConfig.useClusterServers();
|
// 集群模式
|
||||||
if (clusterServersConfig != null) {
|
if (redissonConfig.isClusterConfig()) {
|
||||||
|
ClusterServersConfig clusterServersConfig = redissonConfig.useClusterServers();
|
||||||
password = clusterServersConfig.getPassword();
|
password = clusterServersConfig.getPassword();
|
||||||
clusterServersConfig.setPassword(
|
clusterServersConfig.setPassword(
|
||||||
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReplicatedServersConfig replicatedServersConfig = redissonConfig.useReplicatedServers();
|
|
||||||
if (replicatedServersConfig != null) {
|
|
||||||
password = replicatedServersConfig.getPassword();
|
|
||||||
replicatedServersConfig.setPassword(
|
|
||||||
StringUtils.isEmpty(password) ? null : AesUtils.decrypt(password, publicKey));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user