我正在尝试通过伪装代理多部分请求。
@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:伪装/ Request $ Body错误。
答案 0 :(得分:1)
根据open-feign's github document,请注意伪装形式:
答案 1 :(得分:0)
使用feign-form-spring 3.4.1版本。
Gradle
compile(group: 'io.github.openfeign.form', name: 'feign-form-spring', version: '3.4.1')
行家
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form</artifactId>
<version>3.4.1</version>
</dependency>
答案 2 :(得分:0)
以下配置适用于我:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>${feign.version}</version>
</dependency>
位置: