restTemplate.getForObject

Rsp<ShopNewInfo> rsp = restTemplate.getForObject(url+"&shopId="+Shop.getShopId(), Rsp.class);
Copy the code

Use getForObject method, use the generic receiving, error: information is as follows: Java. Lang. ClassCastException: java.util.LinkedHashMap cannot be cast to com.*.biz.mds.dto.. ShopNewInfo

GetForObject returns the LinkedHashMap

Resttemplate.exchange supports generics

ParameterizedTypeReference<Rsp<ShopNewInfo>> reference = new ParameterizedTypeReference<Rsp<ShopNewInfo> >() {};
ResponseEntity<Rsp<ShopNewInfo>> entity = restTemplate.exchange(reqUrl, HttpMethod.GET,null,reference);
Rsp<ShopNewInfo> rsp = entity.getBody();
Copy the code
public class ZhiyiRsp<T> {
    private T result;
    private boolean success;
}

public class ZhiyiShopNewInfo {
    private Integer id;

    @JsonProperty("shop_id")
    private Long shopId;
}
Copy the code