springboot整合redis,从redis中取数据时出现类型转换异常,

java.util.LinkedHashMap cannot be cast to com.moon.icoresso.pojo.bo.OauthCodeToRedisBO。

原因是进行了重复的序列化,redisTemplate已经进行了序列化,重复序列化会导致类型转换异常。

注释掉以下代码即可:

jackson2JsonRedisSerializer.setObjectMapper(objectMapper);

        redisTemplate.setKeySerializer(new StringRedisSerializer());

        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
        //  redisTemplate.setValueSerializer(new FastJsonRedisSerializer<>(Object.class));
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);