Cannot construct instance of `com.jty.entities.Dept` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate or propertybased Creator)

使用RestTemplate对象访问请求出错

@GetMapping(value = "/consumer/dept/get/{id}")
    public Dept get(@PathVariable Long id){
        return restTemplate.getForObject(REST_URL_PREFIX+"/dept/get/"+id,Dept.class);
    }

Cannot construct instance of com.jty.entities.Dept (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

原因是缺少构造函数、或者定义了有参构造函数、没定义无参构造函数

原文地址:https://www.cnblogs.com/jinit/p/12495641.html