mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-17 20:45:06 +08:00
初始化 redis 配置类
This commit is contained in:
@ -34,7 +34,7 @@ public class DBConfigRepository extends AbstractConfigRepository {
|
||||
}
|
||||
|
||||
private final ConfigUtil m_configUtil;
|
||||
private PropertiesFactory propertiesFactory;
|
||||
private final PropertiesFactory propertiesFactory;
|
||||
private final String m_namespace;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.dashboard.framework.redis.config;
|
||||
|
||||
import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
|
||||
// 创建 RedisTemplate 对象
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
// 设置 RedisConnection 工厂。😈 它就是实现多种 Java Redis 客户端接入的秘密工厂。感兴趣的胖友,可以自己去撸下。
|
||||
template.setConnectionFactory(factory);
|
||||
// 使用 String 序列化方式,序列化 KEY 。
|
||||
template.setKeySerializer(RedisSerializer.string());
|
||||
// 使用 JSON 序列化方式(库是 FastJSON ),序列化 VALUE 。
|
||||
template.setValueSerializer(new GenericFastJsonRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user