Can I generate a Spring Feign client with Multipart parameters?

前端 未结 1 1564
醉酒成梦
醉酒成梦 2021-01-12 16:43

I am getting the error: \"Method has too many Body parameters\" when trying to generate a Spring Feign client

@RequestMapping(value=\"/media\", method=Req         


        
相关标签:
1条回答
  • 2021-01-12 17:31

    It should be possible now. Add the following dependencies:

    <dependencies>
    ...
    <dependency>
        <groupId>io.github.openfeign.form</groupId>
        <artifactId>feign-form</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.openfeign.form</groupId>
        <artifactId>feign-form-spring</artifactId>
        <version>2.2.0</version>
    </dependency>
    ...
    

    and use this client configuration:

    @FeignClient(name = "file-upload-service", configuration = FileUploadServiceClient.MultipartSupportConfig.class)
    public interface FileUploadServiceClient extends IFileUploadServiceClient {
    
        @Configuration
        public class MultipartSupportConfig {
    
            @Bean
            @Primary
            @Scope("prototype")
            public Encoder feignFormEncoder() {
                return new SpringFormEncoder();
            }
        }
    }
    

    Example was taken from: feign-form docs

    0 讨论(0)
提交回复
热议问题