feign.codec.EncodeException: Could not write request: no suitable HttpMessageConverter found【已解决】

The main error messages are as follows: 

com.netflix.hystrix.exception.HystrixRuntimeException: xxx#xxx(MultipartFile[],Long) failed and no fallback available. 

Caused by: feign.codec.EncodeException: Could not write request: no suitable HttpMessageConverter found for request type [[Lorg.springframework.web.multipart.MultipartFile;] and content type [multipart/form-data]

 Interpret the exception information as:

Encoding exception: Unable to write request: No suitable HttpMessageConverter[[Lorg.springframework.web.multipart.MultipartFile;] and content type [multipart/form-data] found for request type

 Requirements: Provide an interface that can receive Excel files to the front end, which is used to parse the content in the file and map it into multiple Java objects, and insert them into the database in batches;

Specific scenario:

  1. When postman directly tests the service service, there is no problem;
  2. When the web module calls the service module through openfeign, an encoding exception occurs: Unable to write request: No HttpMessageConverter [[Lorg.springframework.web.multipart.MultipartFile;] and content type [multipart/form-data] suitable for the request type were found.

Found the reason: The @RequestPart annotation is used for the MultipartFile type, and the input parameter type of my interface is MultipartFile[]

Guess you like

Origin blog.csdn.net/m0_73442728/article/details/131845115