Java 序列化接收到的数据类型为';LocalDateTime';
我有一个类Dto,它将设置一个数据类型为Java 序列化接收到的数据类型为';LocalDateTime';,java,spring-boot,Java,Spring Boot,我有一个类Dto,它将设置一个数据类型为LocalDateTime的值 我收到JSON时出错 public class Dto { @JsonFormat(shape = JsonFormat.Shape.STRING) private LocalDateTime scheduledStartTime; } } 以下是错误: Cannot construct instance of `java.time.LocalDateTime` (no Creators, like defau
LocalDateTime
的值
我收到JSON时出错
public class Dto {
@JsonFormat(shape = JsonFormat.Shape.STRING)
private LocalDateTime scheduledStartTime;
}
}
以下是错误:
Cannot construct instance of `java.time.LocalDateTime` (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value ('2019-08-01T15:30:00Z')
尝试禁用:
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
或
在DTO中接收JSON期间或在发送JSON期间?Im new to Serialization/Deserialization
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonSerialize(using = LocalDateTimeSerializer.class)