java.lang.NoClassDefFoundError: feign/Request$Body in feign while adding support for multipart/form-data

java.lang.NoClassDefFoundError: feign/Request$Body in feign while adding support for multipart/form-data

我正在尝试通过假装代理多部分请求。

@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$正文错误。

使用feign-form-spring3.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>

查看要求https://github.com/OpenFeign/feign-form#requirements

根据open-feign's github document,请注意 feign-form的版本:

  • 3.5.0 之前的所有 feign-form 版本都适用于 OpenFeign 9.* 版本;
  • 从 feign-form 的版本 3.5.0 开始,该模块适用于 OpenFeign 10.1.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>

其中:

11.0

Hoxton.SR3