SpringSecurity版本不一致导致序列化失败

问题

今天将springcloud.sr2升级到g版后发现zuul去auth验证信息时失败,auth报以下错误

Handling error: SerializationException, Cannot deserialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to deserialize payload. Is the byte array a result of corresponding serialization for DefaultDeserializer?; nested exception is java.io.InvalidClassException: org.springframework.security.core.authority.SimpleGrantedAuthority; local class incompatible: stream classdesc serialVersionUID = 500, local class serialVersionUID = 510

解决方案

定位到 SimpleGrantedAuthority
可以看到

private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;

查看SERIAL_VERSION_UID
发现注释

/**
* Global Serialization value for Spring Security classes.
*
* N.B. Classes are not intended to be serializable between different versions. See
* SEC-1709 for why we still need a serial version.
*/

大致意思是SpringSecurity不支持跨版本的序列化,但是我这边的确都是用的同一版本为什么会提示不一样呢?
后来在官方issues中看到
在这里插入图片描述
一拍脑袋,我token存入redis中时用的是低版本的SpringSecurity,需要把redis中原有的旧token清空重新生成就可以了

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值