spring boot redis 序列化报错 as a subtype of [simple type, class java.lang.Object]: no such class found
程序员文章站
2022-06-28 16:13:59
redis 原配置 @Bean public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){ //配置redisTemplate RedisTemplate redisTemplate = new RedisTemplate();...
redis 原配置
@Bean
public RedisTemplate<String,Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
//配置redisTemplate
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<String, Object>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
RedisSerializer stringSerializer = new StringRedisSerializer();
......
return redisTemplate;
}
异常信息
org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Could not resolve type id 'com.xxx.BeanVo' as a subtype of [simple type, class java.lang.Object]: no such class found
- 关键信息 as a subtype of [simple type, class java.lang.Object]: no such class found
解决后的配置
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
//配置redisTemplate
RedisTemplate redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
RedisSerializer stringSerializer = new StringRedisSerializer();
......
return redisTemplate;
}
- 其实我只是把创建RedisTemplate对象时指定的泛型去掉了
- 到此问题解决!
本文地址:https://blog.csdn.net/wency935486/article/details/112008465
上一篇: 30个月不卡顿!OPPO Reno5 Pro ColorOS 11上手
下一篇: xml 解析类