Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.ClassCastException: com.jlw.time_is_money.application.user.model.SysUser cannot be cast to com.jlw.time_is_money.application.user.model.SysUser] with root cause
原因是:
要缓存的 Java 对象必须实现 Serializable 接口,因为 Spring 会将对象先序列化再存入 Redis
解决办法:
将缓存实体类继承 Serializable
@Data
@ApiModel("sys_user")
public class SysUser implements Serializable {
private static final long serialVersionUID = -339516038496531943L;