SpringBoot serializes exceptions using Java8 time API

when fetch is used in the front end to make a request, the back end LocalDateTime serializes normally

frontend request code

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.time.LocalDateTime out of START_ARRAY token
 at [Source: {"code":200,"message":null,"data":{"id":1032486183939768321,"startTime":[2018,8,23,13,4,23],"endTime":[2018,8,23,13,40,54]}}; line: 1, column: 103] (through reference chain: com.rx.f3d.common.web.JsonResult["data"]->com.rx.f3d.module.entity.game.Game["startTime"])

so why is the use of SpringTest testing inconsistent with the front end? And how to serialize / deserialize LocalDateTime correctly?

Jun.12,2021

Don't consider why it is inconsistent for the time being.

as a direct serialization class, you can choose a convenient serialization class such as String, or write serialization / deserialization yourself with @ JsonSerialize,@JsonDeserialize. There are generally ready-made annotations such as @ DateFormat for time type serialization.


date format specifies the following format

@Column(name = "startTime")
@DateTimeFormat(iso = DateTimeFormatter.ISO_LOCAL_DATE_TIME)
@JsonFormat(pattern = "YYYY-MM-dd HH:mm")
private LocalDateTime startTime;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3af3a-2c26f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3af3a-2c26f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?