我得到“将请求主体写入服务器时出错;嵌套异常是java.io.IOException:将请求主体写入服务器时出错”使用下面的代码使用带有jar文件作为有效负载的RestTemplate进行POST服务调用
请告诉我这里可能存在的问题
RestTemplate restTemplate = new RestTemplate();
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setBufferRequestBody(false);
restTemplate.setRequestFactory(requestFactory);
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource("*.jar").getFile());
HttpEntity<FileSystemResource> requestEntity = new HttpEntity<>(new FileSystemResource(file));
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);