geekidea / spring-boot-plus

:fire: Spring-Boot-Plus is an easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding. :rocket:
https://springboot.plus
MIT License
2.46k stars 722 forks source link

启用验证码后 登录报错 #158

Closed mixcg closed 3 months ago

mixcg commented 3 years ago

从 redis 取缓存的验证码 jackson 序列化报错

org.springframework.data.redis.serializer.SerializationException: Could not read JSON: Unrecognized token 'kVRf': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')

linmengmeng-1314 commented 3 years ago

io.geekidea.springbootplus.config.RedisTemplateConfig类中设置redis的value时,使用StringRedisSerializer序列化,不使用Json相关序列化 修改RedisTemplateConfig.redisTemplate方法中的

redisTemplate.setValueSerializer(jsonRedisSerializer);

redisTemplate.setValueSerializer(new StringRedisSerializer());

此时由于修改了redis存值的序列化方式,原本直接将对象存入redis的地方会报错,逐步修改redisTemplate.opsForValue().set()的使用,将值对象转成字符串(JSON字符串)后再存值(调用该对象的toString方法或者使用JSON工具类将对象转成JSON字符串)。