我是靠谱客的博主 谦让皮卡丘,最近开发中收集的这篇文章主要介绍因为返回结果对象中没有无参构造方法,导致微服务调用失败,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

因为返回结果对象中没有无参构造方法,导致微服务调用失败

微服务调用失败,弹出错误,超时或未收到返回信息
1.确认了被调用方,postman调用时,能够返回正确结果
2.确认了 FeignClient  的类型,以及服务名称,在gateway中也存在,并且拼写正确
3.打印的日志中,显示信息如下。断点跟踪后,发现错误是 missing default constructor or creator, or perhaps need to add/enable type information?。
  尝试增加无参构造方法后,成功解决问题。

    2020-04-24 13:11:49.888 cc8d76f4 com.netflix.hystrix.exception.HystrixRuntimeException: EquipmentManager#syncEquipmentInfo(SyncEquipmentInfoDTO) timed-out and no fallback available.
    2020-04-24 13:11:49.888 cc8d76f4     at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140)
    2020-04-24 13:11:49.888 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    2020-04-24 13:11:49.889 cc8d76f4     at com.netflix.hystrix.AbstractCommand$FallbackHookApplication$1.onError(AbstractCommand.java:1397)
    2020-04-24 13:11:49.889 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    2020-04-24 13:11:49.889 cc8d76f4     at rx.observers.Subscribers$5.onError(Subscribers.java:230)
    2020-04-24 13:11:49.889 cc8d76f4     at rx.internal.operators.OnSubscribeThrow.call(OnSubscribeThrow.java:28)
    2020-04-24 13:11:49.890 cc8d76f4     at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
    2020-04-24 13:11:49.890 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    2020-04-24 13:11:49.890 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    2020-04-24 13:11:49.891 cc8d76f4     at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48)
    2020-04-24 13:11:49.891 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    2020-04-24 13:11:49.891 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    2020-04-24 13:11:49.892 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41)
    2020-04-24 13:11:49.892 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    2020-04-24 13:11:49.892 cc8d76f4     at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    2020-04-24 13:11:49.892 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30)
    2020-04-24 13:11:49.893 cc8d76f4     at rx.Observable.unsafeSubscribe(Observable.java:10211)
    2020-04-24 13:11:49.893 cc8d76f4     at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:142)
    2020-04-24 13:11:49.893 cc8d76f4     at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onError(OnSubscribeDoOnEach.java:87)
    2020-04-24 13:11:49.893 cc8d76f4     at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:45)
    2020-04-24 13:11:49.893 cc8d76f4     at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable$1.call(HystrixContextRunnable.java:41)
    2020-04-24 13:11:49.894 cc8d76f4     at com.netflix.hystrix.strategy.concurrency.HystrixContextRunnable.run(HystrixContextRunnable.java:61)
    2020-04-24 13:11:49.894 cc8d76f4     at com.netflix.hystrix.AbstractCommand$HystrixObservableTimeoutOperator$1.tick(AbstractCommand.java:1159)
    2020-04-24 13:11:49.894 cc8d76f4     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    2020-04-24 13:11:49.894 cc8d76f4     at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
    2020-04-24 13:11:49.895 cc8d76f4     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    2020-04-24 13:11:49.895 cc8d76f4     at java.lang.Thread.run(Thread.java:748)

 


JSON parse error: Can not construct instance of com.XXX.service.dto.sync.SyncResult:
no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?);
nested exception is com.fasterxml.jackson.databind.JsonMappingException:
 Can not construct instance of com.XXX.service.dto.sync.SyncResult:
 no suitable constructor found, can not deserialize from Object value
 (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: java.io.PushbackInputStream@6d1705d9; line: 2, column: 3]

最后

以上就是谦让皮卡丘为你收集整理的因为返回结果对象中没有无参构造方法,导致微服务调用失败的全部内容,希望文章能够帮你解决因为返回结果对象中没有无参构造方法,导致微服务调用失败所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部