mirror of https://gitee.com/stylefeng/roses
【8.0】【config】系统配置自动识别redis class进行配置容器策略切换
parent
4a5488e2a6
commit
0d46cba194
|
@ -72,8 +72,7 @@ public class ConfigInitListener extends ContextInitializedListener implements Or
|
||||||
ConfigurableEnvironment environment = event.getApplicationContext().getEnvironment();
|
ConfigurableEnvironment environment = event.getApplicationContext().getEnvironment();
|
||||||
|
|
||||||
// 是否采用redis进行sys_config缓存的装载和读取(true/false)
|
// 是否采用redis进行sys_config缓存的装载和读取(true/false)
|
||||||
String redisConfigCacheEnable = environment.getProperty("redis.config.cache.enable");
|
boolean redisConfigCacheEnableFlag = getRedisOpenFlag();
|
||||||
Boolean redisConfigCacheEnableFlag = Convert.toBool(redisConfigCacheEnable, false);
|
|
||||||
|
|
||||||
if (redisConfigCacheEnableFlag) {
|
if (redisConfigCacheEnableFlag) {
|
||||||
// 获取Redis的相关配置
|
// 获取Redis的相关配置
|
||||||
|
@ -127,4 +126,19 @@ public class ConfigInitListener extends ContextInitializedListener implements Or
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Redis的类标识,如果项目中有Redis的Class,则返回true
|
||||||
|
*
|
||||||
|
* @author fengshuonan
|
||||||
|
* @since 2023/8/9 22:40
|
||||||
|
*/
|
||||||
|
private boolean getRedisOpenFlag() {
|
||||||
|
try {
|
||||||
|
Class.forName("org.springframework.data.redis.connection.RedisConnectionFactory");
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue