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

    }

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

相关推荐
云烟成雨TD几秒前
Spring AI Alibaba 1.x 系列【17】模型拦截器(ModelInterceptor)
java·人工智能·spring
Jul1en_2 分钟前
【Redis】List列表命令、编码方式及应用场景
数据库·redis·list
Flittly3 分钟前
【SpringSecurity新手村系列】(1)初识安全框架
java·spring boot·安全·spring·安全架构
身如柳絮随风扬5 分钟前
分布式锁深度剖析:ZooKeeper(CP)与 Redis(AP)的实现原理与对比
redis·分布式·zookeeper
Predestination王瀞潞7 分钟前
Java EE3-我独自整合(第五章:Spring AOP 介绍与入门案例)
java·后端·spring·java-ee
それども11 分钟前
Spring Boot 异常拦截处理机制
java·spring
Mem0rin13 分钟前
[Java/数据结构]PriorityQueue
java·数据结构
阿拉斯攀登15 分钟前
20 个 Android JNI + CMake 生产级示例
android·java·开发语言·人工智能·机器学习·无人售货柜
!停18 分钟前
C++入门STL容器string使用基础
开发语言·c++
m0_7167652319 分钟前
数据结构--栈的插入、删除、查找详解
开发语言·数据结构·c++·经验分享·学习·青少年编程·visual studio