【发布时间】:2017-02-15 22:10:31
【问题描述】:
org.springframework.data.redis.serializer.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 org.springframework.core.NestedIOException:
Failed to deserialize object type;
nested exception is java.lang.ClassNotFoundException: com.foo.user.model.CurrentUser
我有两个典型的 Spring Boot 应用程序,它们共享一个用于会话状态的 Redis 实例。尝试登录我的应用程序时会立即发生上述错误。
我不太确定这里发生了什么 - 两个应用程序对适用的用户模型和 Spring 依赖项使用相同的库和版本。值得CurrentUser 扩展org.springframework.security.core.userdetails.User,它本身就是Serializable。
我已经重新启动了我的 Redis 实例,以为有些东西变得很时髦,但事实并非如此。我会展示我已经尝试过的东西,但主要是确保我的工件正确构建并重新启动应用程序和 Redis 服务器,并稍微玩弄Serializable。
为什么我会看到这个?
【问题讨论】:
-
CurrentUser 的所有成员都可以序列化吗?
-
几个问题:Redis 配置(更具体地说是序列化部分)在两个应用程序中是否相同?如果我理解正确
CurrentUser位于两个应用程序之间共享的外部库中?你在使用 Boot DevTools 吗?重现问题或至少两个应用程序的相关配置部分的示例将很有用。 -
士力架 - 是的。 Vedran - 哪些信息对您有帮助?
-
@BrandonV 你能解决这个问题吗?我面临同样的问题:/
-
@varunkr 我确实解决了这个问题,但不幸的是,我不记得做了什么。对不起。
标签: java spring spring-boot redis spring-session