错误信息:
"Request processing failed; nested exception is feign.codec.DecodeException: Error while extracting response for type [cn.silucaihong.scheduling.common.ResultBean<java.lang.Boolean>] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `cn.silucaihong.scheduling.common.ResultBean` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `cn.silucaihong.scheduling.common.ResultBean` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)\n at [Source: (PushbackInputStream); line: 1, column: 2]",
这个错误表明在使用Feign进行HTTP请求时,尝试将服务器返回的JSON响应反序列化为cn.silucaihong.scheduling.common.ResultBean<java.lang.Boolean>
类型时发生了问题。具体来说,问题似乎出在ResultBean
类的反序列化上,Jackson库无法正确构造ResultBean
的实例。
解决这个问题的步骤可能包括:
-
确认
ResultBean
类的结构:- 确保
ResultBean
类具有默认(无参数)构造函数。Jackson通常需要一个无参构造函数来实例化类。 - 检查
ResultBean
类是否有适当的setter方法,以便Jackson可以将反序列化后的属性设置到实例中。
- 确保
service control:
feign 接口:
注意我这样写是完全正确的
响应对象:
因为feign是通过http请求访问服务的所以可以不实现serializable接口
出现错误的原因是没有空的构造器,加上空的构造器就KO了