错误:
. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: (v2.4.4)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 [com.peng.pojo.User]at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:96)at ............
Caused by: 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 [com.peng.pojo.User]at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:64)at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:33)at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:94)... 68 more
Caused by: java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.peng.pojo.User]at org.springframework.core.serializer.DefaultSerializer.serialize(DefaultSerializer.java:43)at org.springframework.core.serializer.Serializer.serializeToByteArray(Serializer.java:56)at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:60)... 70 more2021-03-30 21:49:41.641 INFO 1396 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'Process finished with exit code -1
错误原因
:序列化异常SerializationException
从下面这句话可以看出原因是pojo实体类User没有序列化
java.lang.IllegalArgumentException: DefaultSerializer requires a Serializable payload but received an object of type [com.peng.pojo.User]
需要的是一个序列化之后的参数,但是我们提供的参数是一个Object
解决方法
让这个实体类实现Serializable接口即可