(数据类)实体。JAVA
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class Entity implements Serializable {
private String id;
private String name;
private String status;
private ZonedDateTime registrationDatetime;
private ZonedDateTime updatedDatetime;
private ZonedDateTime createdDatetime;
}
(数据类)实体。JAVA
@Data
@AllArgsConstructor
@JsonDeserialize
public class Entities implements Serializable {
private List<Entity> entities;
}
我试着说:
TypeReference<ResponseModel<Entities>> typeReference = new TypeReference<ResponseModel<Entities>>() {};
ResponseModel<Entities> response = objectMapper.readValue(result.getResponse().getContentAsString(), typeReference);
我犯了一个错误:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `model/Entities` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
我已经把@JsonDeserialize
和实现了可序列化
我错过了什么?
尝试给@NoArgsConstructor也实体类。这应该行得通。