通过feign接口返回的分页列表IPage,出现报错,具体报错内容如下:
feign.codec.DecodeException: Type definition error: [simple type, class com.baomidou.mybatisplus.core.metadata.IPage]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.baomidou.mybatisplus.core.metadata.IPage` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
通过对该问题的分析,因为com.baomidou.mybatisplus.core.metadata.IPage是一个接口,所以不能构建实例。抽象类型需要映射到实现类型,可以通过自定义反序列化或者包含额外的类型信息。
接下来,我们可以通过这个提示,自定义一个反序列化类来处理该问题,具体代码如下:
public class IPageDeserializer extends StdDeserializer<IPage> {
protected IPageDeserializer(Class<?> vc) {
super(vc);
}
/**
* Method that can be called to ask implementation to deserial