我正在使用 Springs Feign Client 功能从一个微服务与另一个微服务进行通信。
现在,被调用的服务公开了一个 REST 接口,该接口接受一个文件和一个相关的 (JSON) 对象。
@RequestMapping(value = {CONVERT_PATH, APPLICATION_PATH + CONVERT_PATH}, method = RequestMethod.POST, produces = CONTENT_TYPE)
public ResponseEntity<InputStreamResource> convert(@RequestPart("file") MultipartFile file, @RequestParam("input") Input in) {...}
该接口运行良好,我已通过从不同来源向其发送有效的多部分/混合实体来验证这一点。
然后,在我的其他服务中,我设置了一个匹配的 feign 客户端来使用这个接口:
@FeignClient("convert")
public interface ConvertClient {
@RequestMapping(value = CONVERT_PATH, method = RequestMethod.POST, consumes = "multipart/mixed")
ResponseEntity<InputStreamResource> convert(@RequestPart("file") MultipartFile file, @RequestPart("input") Input in);
}
同样,从一个服务到另一个服务的连接正在工作,我已经在 feign 客户端(一个不使用多个部分)中使用不同的请求接口验证了这一点。
当我尝试使用此特定接口方法构建(客户端)服务时,出现以下异常:
FactoryBean threw exception on object creation;
nested exception is java.lang.IllegalStateException: Method has too many Body parameters:
public abstract org.springframework.http.ResponseEntity <..>.feign.ConvertClient.convert(org.springframework.web.multipart.MultipartFile,<..>.Input)
我能做些什么来完成这项工作吗?正如我所说,它可以到达 REST 接口,并且不同的 feign 调用正在工作。如果我没记错的话,这应该可行。Springs Feign 只是不支持 feign 接口的 multipart/mixed 吗?