在SpringCloud中使用feign调用路径中,不能在类上直接添加@RequestMapping(value = "/hospital-auth")作为公共路径
@FeignClient(path = "/hospital-auth",value = "hospital-auth", fallback = HospitalFallBack.class, configuration = FeignMultipartSupportConfig.class)
package com.zhiyis.framework.service.remote.feign;
import com.zhiyis.common.report.ResponseReport;
import com.zhiyis.framework.service.remote.config.FeignMultipartSupportConfig;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
/**
* @author laoliangliang
* @date 2018/11/2 13:55
*/
@FeignClient(path = "/hospital-auth",value = "hospital-auth", fallback = HospitalFallBack.class, configuration = FeignMultipartSupportConfig.class)
public interface HospitalFeign {
@RequestMapping(value = "/rpc.api", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
ResponseReport doRemoteCall(@RequestParam(value = "report", required = false) String report, @RequestPart(value = "file", required = false) MultipartFile multipartFile);
@RequestMapping(value = "/rpc.api")
ResponseReport doRemoteCall(@RequestParam(value = "report", required = false) String report);
}
@Component
class HospitalFallBack implements HospitalFeign {
@Override
public ResponseReport doRemoteCall(String report, MultipartFile multipartFile) {
ResponseReport responseReport = new ResponseReport();
responseReport.returnError("9999", "HospitalFeign 医院服务调用失败");
return responseReport;
}
@Override
public ResponseReport doRemoteCall(String report) {
ResponseReport responseReport = new ResponseReport();
responseReport.returnError("9999", "HospitalFeign 医院服务调用失败");
return responseReport;
}
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有