ResponseEntity结果为linkedHashMap?报类型转换异常

ResponseEntity exchange = restTemplate().exchange("http://127.0.0.1:8080", HttpMethod.GET, entity,List.class)    ;

结果始终为linkedHashMap???

启迪:https://blog.csdn.net/amosryan/article/details/54019479

解决方法:

@Bean
@LoadBalanced
RestTemplate restTemplate() {
    return new RestTemplate();
}
ResponseEntity> exchange = restTemplate()
        .exchange("http://127.0.0.1:8080/getNC?createTime="
                        +qcReportbillNcVo.getCreateTime()+"&code="
                        +qcReportbillNcVo.getCode()+"&workshopPK="
                        +qcReportbillNcVo.getWorkshopPK()+"×="
                        +qcReportbillNcVo.getTimes(),
                HttpMethod.GET, null, new ParameterizedTypeReference>(){});

if (exchange.getStatusCode() == HttpStatus.OK) {
    return exchange.getBody();
}
 
  
List nclist = exchange.getBody()

你可能感兴趣的:(error)