FeignClient接口格式

FeignClient接口格式报错信息:{"timestamp":1648015711758,"status":404,"error":"Not Found"

FeignClient接口格式

FeignClient接口格式 报错信息: {"timestamp":1648015711758,"status":404,"error":"Not Found","message":"No message available","path":"/getDto"}

/order/getDto 完整的地址。

2022-03-23 14:45:40.188 [SimpleAsyncTaskExecutor-1] ERROR [03964e0b1ec5783d,03964e0b1ec5783d] o.s.a.i.SimpleAsyncUncaughtExceptionHandler#handleUncaughtException [line:38] - Unexpected error occurred invoking async method: xxx java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to XXXDTO

代码语言:javascript代码运行次数:0运行复制
//标准写法
@FeignClient(name="order-api")
public interface FeignTestService {

    @GetMapping("/order/getDto")   //url必须要完整
    public ResponseData<OrderDTO> getOrderDto(@RequestParam(value = "orderNo") String orderNo);   //ResponseData后面的泛型带上类型,避免调用方接收需要类型转换

}

@Data
public class ResponseData<T> {

    @AutoDocProperty(value = "返回代码")
    private String resCode;
    @AutoDocProperty(value = "返回消息")
    private String resMsg;
    @AutoDocProperty(value = "返回实体")
    private T data;
    
}


//                LinkedHashMap hashMap = (LinkedHashMap) responseData.getData();
                //json转对象
//                OrderDTO dto = JSON.parseObject(JSON.toJSONString(hashMap), OrderDTO.class);

//正确的接收方法:
                OrderDTO dto = responseData.getData();
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2022-03-23,如有侵权请联系 cloudcommunity@tencent 删除对象泛型接口privatepublic

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754987918a5224388.html

相关推荐

  • FeignClient接口格式

    FeignClient接口格式报错信息:{"timestamp":1648015711758,"status":404,"error":"Not Found"

    1月前
    130

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信