java.lang.NoClassDefFoundError: feign/Request$Body в feign при добавлении поддержки multipart/form-data

Я пытаюсь проксировать составной запрос через feign.

@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.


person Nitish Kumar    schedule 11.04.2019    source источник


Ответы (3)


Используйте версию 3.4.1 feign-form-spring.

Грейдл

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.

person Larry    schedule 29.04.2019

Согласно документу open-feign на github, обратите внимание на симуляцию версии формы:

  • все выпуски фиктивных форм до 3.5.0 работают с версиями OpenFeign 9.*;
  • начиная с версии 3.5.0 feign-form, модуль работает с версиями OpenFeign 10.1.0 и выше.
person David Ding    schedule 05.09.2019

У меня работает следующий конфиг:

    <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‹/притворная.версия›

‹spring-cloud.version›Hoxton.SR3‹/spring-cloud.version›

person Trung Bui Thanh    schedule 16.07.2020