@Configuration
public class RedisConfig {
@Bean
public RedisSerializer fastJsonJsonRedisSerializer() {
return new FastJsonRedisSerializer(Object.class);
}
@Bean
public RedisTemplate initRedisTemplate(RedisConnectionFactory redisConnectionFactory, RedisSerializer fastJsonJsonRedisSerializer) throws Exception {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setValueSerializer(fastJsonJsonRedisSerializer);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}