当我尝试将对象添加到会话中时,如下所示:
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
?
答案 0 :(得分:3)
我猜这个异常已经告诉你出了什么问题。
只需尝试MyObject
实施Serializable