美文网首页
Redis序列化key乱码

Redis序列化key乱码

作者: Bigglesworth | 来源:发表于2023-06-25 11:53 被阅读0次
    @Configuration
    public class RedisConfig {
        @Bean
        public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
            RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
            redisTemplate.setConnectionFactory(redisConnectionFactory);
            // 设置key的序列化规则和value的序列化规则
            redisTemplate.setKeySerializer(new StringRedisSerializer());
            redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
            redisTemplate.afterPropertiesSet();
            return redisTemplate;
        }
    }
    

    相关文章

      网友评论

          本文标题:Redis序列化key乱码

          本文链接:https://www.haomeiwen.com/subject/gwuiydtx.html