【问题标题】:Adding object to HttpSession fails in SpringBoot with Redis使用 Redis 在 Spring Boot 中将对象添加到 Http Session 失败
【发布时间】:2016-04-10 04:38:53
【问题描述】:

当我尝试将对象添加到会话中时:

HttpSession session = ....
MyObject object = ....
session.setAttribute("my_object", object);

然后我得到一个异常:

org.springframework.data.redis.serializer.SerializationException: 
Cannot serialize; nested exception is   
org.springframework.core.serializer.support.SerializationFailedException:
Failed to serialize object using DefaultSerializer; nested exception is 
java.lang.IllegalArgumentException: DefaultSerializer requires a  
Serializable payload but received an object of type [MyObject]

我应该如何指示 REDIS 序列化对象MyObject

【问题讨论】:

    标签: java redis spring-boot httpsession


    【解决方案1】:

    我猜这个异常已经告诉你出了什么问题。 只需尝试让MyObject 实现Serializable

    【讨论】:

      猜你喜欢
      • 2015-04-19
      • 2018-06-06
      • 2018-12-16
      • 1970-01-01
      • 1970-01-01
      • 2017-11-02
      • 1970-01-01
      • 2021-07-21
      • 1970-01-01
      相关资源
      最近更新 更多