首页 > 解决方案 > 无法设置此响应实体方法

问题描述

@HystrixCommand(commandKey = "MyHystrixCommand", fallbackMethod = "myHystrixFallback", threadPoolKey = "ThreadPoolKey")
    public ResponseEntity<String> getServiceCallResponse(String serviceUrl, HttpEntity<?> entity) {
    ResponseEntity<String> resp = null;
    try {
        resp = restTemplate.exchange(serviceUrl, HttpMethod.POST, entity, String.class)
                        .getBody();
    }
    catch(Exception e) {
        handleExceptionForHystrix("getServiceCallResponse", e);
    }
    return resp;
}

设置 resp 时出错,说它不匹配。无法理解为什么会这样。有什么可以替代的。

标签: javaentityresponse

解决方案


推荐阅读