请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Redis 反序列化失败

在UserDetailsService 返回的是一个 userAdminEntity,是可以存到Redis里的,在读取的时候就报错了 spring security 的报错,就是反序列化失败org.springframework.data.redis.serializer.SerializationException: Could not read JSON: The class with net.sdake.ace.admin.entity.UserAdminEntity and name of net.sdake.ace.admin.entity.UserAdminEntity is not whitelisted. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See https://github.com/spring-projects/spring-security/issues/4370 for details (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: The class with net.sdake.ace.admin.entity.UserAdminEntity and name of net.sdake.ace.admin.entity.UserAdminEntity is not whitelisted. If you believe this class is safe to deserialize, please provide an explicit mapping using Jackson annotations or by providing a Mixin. If the serialization is only done by a trusted source, you can also enable default typing. See https://github.com/spring-projects/spring-security/issues/4370 for details (through reference chain: org.springframework.security.core.context.SecurityContextImpl["authentication"])叫我看这个链接我也看不明白上面的序列化器是在这里找到的但是如果登录后返回的是UserDetails 的 user对象的话就完全没问题JSON反序列化是可以的。但是这样我得不到用户的信息了。如果不配置序列化器,使用默认的JDK的序列化的话,userAdminEntity是完全可以返回的请老师解答,给配个序列化器

正在回答 回答被采纳积分+3

插入代码

1回答

JoJo 2018-09-20 10:08:53

这个我也没碰到过,应该是你的UserAdminEntity里的某些属性没法序列化造成的,不要用json序列化吧,急用默认的JDK序列化不行么?

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号