我想像这样使用 Feign 上传文件:
@FeignClient(name = "GDC", url = "${gdc.url}", configuration = ApiConfig.class)
public interface GDCClient {
@RequestMapping(method = RequestMethod.POST, value = "/v1/document", consumes
="multipart/form-data")
Response saveDocument(@RequestPart(value = "file") MultipartFile fileSaveDocumentDTO,
@RequestPart(value = "document") SaveDocumentDTO saveDocumentDTO);
}
但是当我调用 saveDocument 时出现这个错误:
*java.lang.NoSuchFieldError: MULTIPART_RELATED
at org.springframework.cloud.openfeign.support.SpringEncoder.isMultipartType(SpringEncoder.java:227) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]
at org.springframework.cloud.openfeign.support.SpringEncoder.encode(SpringEncoder.java:102) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]
at org.springframework.cloud.openfeign.support.PageableSpringEncoder.encode(PageableSpringEncoder.java:101) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]*
有人可以帮助我吗? :)
最佳答案
OpenFeign 依赖类 org.springframework.cloud.openfeign.support.SpringEncoder
包含来自 org.springframework.http.MediaType
的常量 MULTIPART_RELATED
。 org.springframework.cloud:spring-cloud-starter-openfeign:2.2.8.RELEASE
和以上版本在 SpringEncoder 类中包含此 MULTIPART_RELATED
。我正在使用 2.2.7.RELEASE
关于java - 打开Feign java.lang.NoSuchFieldError : MULTIPART_RELATED Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67927242/