Feign调用传输文件异常

2022年7月24日08:16:11

1. Current request is not a multipart request

feign接口参数使用@RequestPart 而非@RequestParam, 同时需要指定consumes,比如这样:

@PostMapping(value="/upload",consumes= MediaType.MULTIPART_FORM_DATA_VALUE)
    Result<FileStorage>upload(@RequestPart(value="file") MultipartFile file);

2. Feign failed and no fallback

这是hystrix导致,关闭feign熔断,或者延长熔断的超时时间,我简单粗暴的直接关了

3.Read timed out executing POST for “xxx”

配置了hystrix还不行,或者延长ribbon的超时时间,参考了Feign超时问题的办法,简单来说就是feign经过了ribbonnhystrix两级调用,而且都有一个默认的超时时间,延长超时时间就好了

spring:servlet:context-path: /farmapplication:name: farmprofiles:active: devmain:allow-bean-definition-overriding:trueeureka:client:service-url:defaultZone: http://127.0.0.1:7001/eurekainstance:prefer-ip-address:true#关闭feign熔断feign:hystrix:enabled:false#开启熔断,关闭熔断超时或延长调用超时时间#hystrix:#  command:#    default:#      execution:#        timeout:#          enabled: false#        isolation:#          thread:#            timeoutInMilliseconds: 30000#延长ribbon超时时间ribbon:ReadTimeout:30000ConnectTimeout:30000
  • 作者:老飞pfy
  • 原文链接:https://blog.csdn.net/manic_pfy/article/details/113394437
    更新时间:2022年7月24日08:16:11 ,共 997 字。