java中如何在项目启动时将一些配置信息加载到Redis中

一、在项目启动时将一些数据库配置信息加载到Redis中

java 复制代码
 /**
     * 初始化配置参数到缓存中
     */
    @PostConstruct
    private void init() {
        Map<Long, Config> configMap = new HashMap<>();
        List<Config> list = attributionConfigDao.selectList(new LambdaQueryWrapper<Config>());
        if (CheckUtils.isNotEmpty(list)){
            for (Config attributionConfig : list) {
                configMap.put(attributionConfig.getSysOrgId(),attributionConfig);
            }
            redisTemplate.opsForHash().putAll("attributionMap", configMap);
        }

    }

点赞加关注,持续更新中!!!

相关推荐
郝学胜-神的一滴30 分钟前
Effective Python 条款44:善用属性注解
开发语言·c++·vscode·python·算法·stl
代码不停35 分钟前
Redis特殊类型
redis·bootstrap
金銀銅鐵11 小时前
带您看懂字节码指令(番外二):递归里有什么——三层 fact 帧怎么叠起来
java·jvm·后端
两点王爷13 小时前
Java 面试高频:JWT、Cookie、Session、Token 鉴权详解
java·开发语言·面试
微笑星河q14 小时前
C++高阶之【多态】
开发语言·c++
悟道书生15 小时前
hashMap/hashSet/hashCode详解
java
nice_lcj52016 小时前
依赖注入的三种方式:构造器、Setter、字段怎么选
java·spring·面试·依赖注入·字段注入·构造器注入
噢,我明白了16 小时前
实际项目导出方式应用
java·状态模式·导出