Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在SpringBoot中使用@FeignClient上传文件_Java_Spring Boot_Feign - Fatal编程技术网

Java 在SpringBoot中使用@FeignClient上传文件

Java 在SpringBoot中使用@FeignClient上传文件,java,spring-boot,feign,Java,Spring Boot,Feign,我有两个应用程序,都在SpringBoot上。我正在尝试使用@FeignClient 下面是接受文件上传的控制器代码 @PostMapping( path=“/result/output/{resultId}”, consumes=MediaType.MULTIPART\u FORM\u DATA\u VALUE) @ResponseStatus(HttpStatus.OK) 公共结果uploadOutputProviderMetadata(@PathVariable(value=“result

我有两个应用程序,都在SpringBoot上。我正在尝试使用
@FeignClient

下面是接受文件上传的控制器代码

@PostMapping(
path=“/result/output/{resultId}”,
consumes=MediaType.MULTIPART\u FORM\u DATA\u VALUE)
@ResponseStatus(HttpStatus.OK)
公共结果uploadOutputProviderMetadata(@PathVariable(value=“resultId”)UUID resultId,
@RequestParam(“文件”)多部分文件(多部分文件){
返回resultService.storeResult(providerSearchTaskId,getString(multipartFile));
}
以下是此控制器的测试代码段调用

新建MockMultipartFile(
“文件”,
file.getName(),
“应用程序/zip”,
readFileToByteArray(文件));
var resultAsString=getMockMvc()
.执行(MockMvcRequestBuilders)
.multipart(“/private/api/v1/result/output/”+resultId.toString(),getPort())
.file(多部分文件)
.contentType(MediaType.MULTIPART\u表单\u数据)
)
.andExpect(状态().isOk())
安德烈图恩先生()
.getResponse()
.getContentAsString();
测试正常,MvcMock可以使用
MockMultipartFile
MediaType.MULTIPART\u FORM\u DATA

这是我可怜的伪装客户端,来自另一个试图上传文件的应用程序

@FeignClient(name=“Client”,url=“${server.url}”)
特征上传客户端{
@邮戳(
path=Array(“/private/api/v1/result/output/{resultId}”),
消耗=数组(MediaType.MULTIPART\u FORM\u DATA\u VALUE))
def uploadResult(@PathVariable resultId:UUID,
@RequestPart(name=“file”)文件:多值映射[字符串,对象]:结果
}
}
@配置
@enablefignclients(clients=Array(classOf[UploadClient]))
类FeignActivationConfiguration{
@豆子
def clientFeignEncoder(messageConverters:ObjectFactory[HttpMessageConverters]):编码器={
新SpringFormEncoder(新SpringEncoder(messageConverters))
}
}
我有e2e测试和假摔

status 400 reading AdsManagerClient#uploadResult(UUID,MultiValueMap)
feign.FeignException$BadRequest: status 400 reading UploadClient#uploadResult(UUID,MultiValueMap)

为什么?

我添加了错误解码器,控制器的信息量不大

//错误响应代码:400,响应文本:错误,原因:null
val errorMessage=s“调用$methodKey时,错误响应代码:${response.status()},responseText:$responseText,原因:${response.reason()}”