这是我的消费者请求功能:
@PostMapping(value = "/spuSkuInfo")
public DataResponseDto<Map<String, Object>> addSpuAndSkuInfo(@Valid SpuSkuInfoBo spuSkuInfoBo) {
String url = REST_URL_PREFIX + "addSpuAndSkuInfo";
DataResponseDto<Map<String, Object>> dataResponseDto;
MultiValueMap<String,SpuSkuInfoBo> reqMap = new LinkedMultiValueMap<>();
reqMap.add("spuSkuInfoBo",spuSkuInfoBo);
HttpEntity<MultiValueMap<String,SpuSkuInfoBo>> httpEntity = new HttpEntity<>(reqMap);
dataResponseDto = restTemplate.postForObject(url,httpEntity,DataResponseDto.class);
}
这是我的提供者:
@PostMapping(value = "/addSpuAndSkuInfo")
public DataResponseDto<Map<String, Object>> addSpuAndSkuInfo(SpuSkuInfoBo spuSkuInfoBo) {
DataResponseDto<Map<String, Object>> responseDto;
try {
responseDto = spuSkuService.addSpuAndSkuInfo(spuSkuInfoBo);
} catch (Exception e) {
logger.error("addSpuAndSkuInfo", e);
responseDto = new DataResponseDto<>();
responseDto.setRspCd(PrdErrorCode.PRD_FAIL_CD);
responseDto.setRspInf("");
return responseDto;
}
return responseDto;
}
在消费者中,我可以获得Pojo'SpuSkuInfoBo' 而且,当我在提供程序中调试程序时,我只是无法收到请求正文“ SpuSkuInfoBo”
答案 0 :(得分:0)
最后,我通过在提供程序函数中添加@RequstBody解决了该问题
public DataResponseDto<Map<String, Object>> addSpuAndSkuInfo(@RequestBody SpuSkuInfoBo spuSkuInfoBo)