轉載於:https://blog.csdn.net/weixin_43333483/article/details/99219156
一、首先貼一段錯誤信息
feign.codec.DecodeException: Type definition error: [simple type, class com.xuecheng.framework.domain.cms.response.CmsPageResult]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.xuecheng.framework.domain.cms.response.CmsPageResult` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (PushbackInputStream); line: 1, column: 2]
二、看我的feign 接口
-
-
public interface CmsPageClient {
-
//保存
-
-
public CmsPageResult save( CmsPage cmsPage);
-
}
三、返回對象
-
-
public class CmsPageResult extends ResponseResult {
-
-
//模型對象 操作是
-
CmsPage cmsPage;
-
-
-
public CmsPageResult( ResultCode resultCode, CmsPage cmsPage) {
-
super(resultCode);
-
this.cmsPage = cmsPage;
-
}
-
-
}
四、有此看出,我上面的是返回模型是沒有無參構造方法的返回,那么我們填上無參構造的注解,就不報異常了
-
-
//無參的構造方法
-
public class CmsPageResult extends ResponseResult {
-
-
//cms 操作是
-
CmsPage cmsPage;
-
-
public CmsPageResult( ResultCode resultCode, CmsPage cmsPage) {
-
super(resultCode);
-
this.cmsPage = cmsPage;
-
}
-
-
}
五、總結
首先我們來了解一下Fegin
Feign是Netflix公司開源的輕量級rest客戶端,使用Feign可以非常方便的實現Http 客戶端。Spring Cloud引入
Feign並且集成了Ribbon實現客戶端負載均衡調用(Ribbon是Netflix公司開源的一個負載均衡的項目(https://github.com/Netflix/ribbon),它是一個基於 HTTP、
TCP的客戶端負載均衡器)