Nil*_*orn 5 java rest spring netflix-feign
我正在使用 Springs Feign Client 功能从一个微服务到另一个微服务进行通信。
现在,被调用的服务公开了一个接受文件和相关 (JSON) 对象的 REST 接口。
@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) {...}
Run Code Online (Sandbox Code Playgroud)
这个接口运行良好,我已经通过从不同的来源向它发送一个有效的多部分/混合实体来验证这一点。
然后,在我的其他服务中,我设置了一个匹配的假客户端来使用这个接口:
@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);
}
Run Code Online (Sandbox Code Playgroud)
同样,从一个服务到另一个服务的连接正在工作,我已经在 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)
Run Code Online (Sandbox Code Playgroud)
有什么我可以做的吗?正如我所说的,它可以到达 REST 接口,并且不同的伪装调用正在工作。如果我没记错的话,这应该可行。Springs Feign 只是不支持 feign 接口的 multipart/mixed 吗?
归档时间: |
|
查看次数: |
9858 次 |
最近记录: |