我正在尝试将HttpServletRequest路由到另一个微服务,其中请求可能包含多部分请求或任何常规请求。但是在发送时出现以下错误。
注意:我不想修改请求,因为我试图编写一些通用方法。
public Object doPostCall(HttpServletRequest request, String requestURL, String rootURL)
throws URISyntaxException, IOException, ServletException {
RestTemplate restTemplate = new RestTemplate();
final String url = rootURL + requestURL;
uri = new URI(url);
try {
result2 = restTemplate.postForEntity(uri, request, Object.class);
System.out.println("after service call" + result2);
} catch (RestClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result2;
}
com.fasterxml.jackson.databind.exc.InvalidDefinitionException :
No serializer found for class java.util.Collections$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.web.multipart.support.StandardMultipartHttpServletRequest["request"]->org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper["request"]->org.apache.catalina.connector.RequestFacade["attributeNames"])
甚至我都尝试在属性文件中设置此设置。 spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
,但是它不起作用
我的消费控制器如下:
@PostMapping(value = "/v1/upload/{moduleName}/{fileType}", produces = "application/json")
public ResponseEntity<Object> uploadFiles(@RequestPart("file") List<MultipartFile> inputFileList,
@RequestParam(value = "createdBy", required = false) String createdBy, @PathVariable String moduleName,
@RequestParam(value = "catalogId", required = false) String catalogId,
@RequestParam(value = "catalogName", required = false) String catalogName, @PathVariable String fileType) {