Redis集群配置SpringBoot

https://blog.csdn.net/qq_31256487/article/details/83144088

http://www.zhihengshi.com/2019/04/18/%E8%AE%B0%E4%B8%80%E6%AC%A1RedisLettuce%E8%BF%9E%E6%8E%A5%E6%B1%A0ConnectionResetByPeer%E6%8E%92%E6%9F%A5%E7%BB%8F%E5%8E%86/

@Configuration
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisConfig {

    @Bean
    public RedisTemplate<String, Object> redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        template.setKeySerializer(new StringRedisSerializer());
        template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
        redisConnectionFactory.setValidateConnection(true);
        template.setConnectionFactory(redisConnectionFactory);
        return template;
    }
}

猜你喜欢

转载自blog.csdn.net/rlk512974883/article/details/103628479