Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jac

postman调用接口报错

“type”: “https://www.jhipster.tech/problem/problem-with-message”,
“title”: “Internal Server Error”,
“status”: 500,
“detail”: “Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of java.time.Instant (no Creators, like default construct, exist): no String-argument constructor/factory method to deserialize from String value (‘2020-03-19 11:02:58’)\n at [Source: (PushbackInputStream); line: 3, column: 18] (through reference chain: com.cplh.gis.service.dto.ProcessFlowDTO[“createdDate”])”,
“path”: “/api/processFlow”,
“message”: “error.http.500”

原因是实体类继承AbstractAuditingEntity审计功能,其中的createdDate和lastModifiedDate字段是Instant类型的,json对其进行序列化和反序列化会报错。

解决办法

在审计类的字段加上@JsonIgnore注解就解决了。
Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jac_第1张图片

更新一下:::
还有一种情况:
实体类的DTO没有实现序列化,
Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jac_第2张图片

你可能感兴趣的:(Type definition error: [simple type, class java.time.Instant]; nested exception is com.fasterxml.jac)