0
類
public class RestResponseDto {
private Boolean status;
private Object data;
private Object error;
public RestResponseDto(Boolean status, Object data, Object error) {
this.status = status;
this.data = data;
this.error = error;
}
//Getters and setters
}
我試圖打我的另一個REST API(GET請求),並映射到這個類的響應。
RestTemplate restTemplate = new RestTemplate();
RestResponseDto result = restTemplate.getForObject(uri, RestResponseDto.class);
但我收到以下錯誤:
Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not construct instance of xxx.xxx.xxx.xxx: no suitable constructor found, can not deserialize from Object value (missing default constructor or creator, or perhaps need to add/enable type information?);
您有缺省的無參數構造函數嗎? –