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);
        }

    }

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

相关推荐
是小蟹呀^5 小时前
Spring Security + JWT 面试题整理
java·jwt·springsecurity
星栈独行7 小时前
翻完 Pi 源码:它和 Codex、Claude Code 有何不同
开发语言·javascript·人工智能·程序人生
spencer_tseng8 小时前
Redis + Nacos.bat
java·windows·dos
qq_448011168 小时前
C语言中的变量和函数的定义与声明
android·c语言·开发语言
她说可以呀8 小时前
Redis哨兵
数据库·redis·bootstrap
troyzhxu8 小时前
列表查询的 GraphQL —— 一行代码终结你的 if-else 地狱!
java·springboot·graphql
孫治AllenSun9 小时前
【DataX】生产环境搭建DataX集群案例
java·开发语言·jvm
c2385610 小时前
把 C++ 内存分配拆透:new 与 malloc 的三层血缘
开发语言·c++·算法
好好沉淀10 小时前
@NotBlank(message = “{xxx}“) 注解中花括号的含义
java