Friday, September 3, 2021

Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value

 JSON parse error: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value


You need jackson dependency for this serialization and deserialization.


Gradle:

compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.4")

Maven:

<dependency>

    <groupId>com.fasterxml.jackson.datatype</groupId>

    <artifactId>jackson-datatype-jsr310</artifactId>

</dependency>

Add this code where you are using OBJECT_MAPPER to convert.

@PostConstruct
public void setObjectMapper() {

OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

OBJECT_MAPPER.registerModule(new JavaTimeModule());

    }

No comments:

Post a Comment