原因是 springboot 的RedisTemplate默认使用的是jdk的反序列化组件
解决办法 新建一个配置类
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory){
RedisTemplate template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
//字符串序列化方法
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
}



