场景:使用Redis缓存,将方法的返回值缓存.方法内部调用了SubList()这个方法.
原因:subList方法返回的是一个List,这个List是一个interface,继承自Collection, 而且Collection也是interface,是没有实现Serializable接口的,所以不能序列化/反序列化。
解决方法:
// 原错误代码
bannerList = bannerList.subList(0, SLIDING_SIZE);
// 修改后的正确代码
bannerList = new ArrayList<>(bannerList.subList(0, SLIDING_SIZE));
Could not read JSON: Cannot construct instance of `java.util.ArrayList$SubList`
最新推荐文章于 2024-08-04 11:07:52 发布