mysql的date默认格式为 yyyy-MM-dd
通过MyBatis Plus 代码生成器默认生成的entity及dto类型为LocalDateTime, 此时出入 yyyy-MM-dd参数时,会报类型异常,无法解析。
需修改格式为LocalDate。
如:
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate publishDate;
参考:
@JsonSerialize(using = LocalTimeSerializer.class) @JsonFormat(pattern = "HH:mm:ss") private LocalTime xxx; @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime xxx; @JsonSerialize(using = LocalDateSerializer.class) @JsonFormat(pattern = "yyyy-MM-dd") private LocalDate xxx;
https://blog.csdn.net/weixin_43840323/article/details/120077245
https://www.cnblogs.com/codecat/p/10845797.html