DefaultSerializer requires a Serializable payload but received an object of type

时间:2025-02-17 17:37:30
在使用SpringBoot自带的缓存注解@EnableCaching和@Cacheable时,报错DefaultSerializer requires a Serializable payload but received an object of type。要缓存的 Java 对象必须实现 Serializable 接口,因为 Spring 会将对象先序列化再存入 Redis,将缓存实体类继承 Serializable。