java.lang.NoClassDefFoundError:feign / Request $ body in feign,同时添加对multipart / form-data的支持

问题描述 投票:0回答:1

我试图通过假装代理多部分请求。

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

multipartform-data noclassdeffounderror feign
1个回答
0
投票

使用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>

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

© www.soinside.com 2019 - 2024. All rights reserved.