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

    }

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

相关推荐
MaCa .BaKa12 分钟前
35-疫苗预约管理系统(微服务)
spring boot·redis·微服务·云原生·架构·springcloud
triticale12 分钟前
【蓝桥杯】P12165 [蓝桥杯 2025 省 C/Java A] 最短距离
java·蓝桥杯
Felven12 分钟前
A. Ideal Generator
java·数据结构·算法
秋野酱20 分钟前
基于 Spring Boot 的银行柜台管理系统设计与实现(源码+文档+部署讲解)
java·spring boot·后端
JAVA学习通34 分钟前
JAVA多线程(8.0)
java·开发语言
不当菜虚困37 分钟前
JAVA设计模式——(七)代理模式
java·设计模式·代理模式
Luck_ff081037 分钟前
【Python爬虫详解】第四篇:使用解析库提取网页数据——BeautifuSoup
开发语言·爬虫·python
学渣6765644 分钟前
什么时候使用Python 虚拟环境(venv)而不用conda
开发语言·python·conda
joke_xiaoli1 小时前
tomcat Server 连接服务器 进展
java·服务器·tomcat
想睡hhh1 小时前
c++STL——stack、queue、priority_queue的模拟实现
开发语言·c++·stl