我试图通过假装代理多部分请求。
@PostMapping(value = "{pathUri1}/{pathUri2}",consumes = MediaType.MULTIPART_FORM_DATA_VALUE,produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<BaseResponse<?>> uploadFileCall(@PathVariable(value = "pathUri1") String pathUri1, @PathVariable(value = "pathUri2") String pathUri2, @RequestPart(name = "file") MultipartFile file, @RequestParam Map<Object,Object> requestParam, @RequestHeader HttpHeaders httpHeaders);
这是服务电话。
@Configuration
class MultipartSupportConfig {
@Autowired
ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
@Primary
@Scope("prototype")
public Encoder feignFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}
为multipart / form-data添加了编码器配置。
我跟着这个https://github.com/OpenFeign/feign-form
但我得到的hystrixRunTimeException
是由于java.lang.NoClassDefFoundError引起的:feign / Request $ Body错误。
使用feign-form-spring 3.4.1版本。
摇篮
compile(group: 'io.github.openfeign.form', name: 'feign-form-spring', version: '3.4.1')
Maven的
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form</artifactId>
<version>3.4.1</version>
</dependency>