1、需要配置
@FeignClient(name = "demo", fallbackFactory = TestsServiceClientHystrix.class,configuration = FeignMultipartConfig.class)
2、和目标接口类型保持一直
@PostMapping(value = "/tests/defect/saveDefect",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) RespInfo saveDefect(@RequestPart(value = "file") MultipartFile[] file,@RequestParam(value = "defect") String defect);
3、实现类需要实现FallbackFactory类
@Component @Slf4j public class TestsServiceClientHystrix implements FallbackFactory
@Override
public ITestsServiceClient create(Throwable throwable) {
return new ITestsServiceClient(){
@Override
public RespInfo setAttachmentId(ReportStatusBo reportStatusBo) {
return null;
}
}}
FeignMultipartConfig
package com.newland.devops.core.config;
import com.newland.devops.core.feign.form.spring.FeignMultipartFormEncode;
import feign.form.FormEncoder;
import org.springframework.context.annotation.Bean;
public class FeignMultipartConfig {
public FeignMultipartConfig() {
}
@Bean
public FormEncoder feignMultipartFormEncoder() {
return new FeignMultipartFormEncode();
}
}



