Problem with deserialization of LocalDateTime in Junit test

You create new ObjectMapper in test class:

MyDto dto = new ObjectMapper().readValue(json, MyDto.class);

Try to inject ObjectMapper from Spring context or manually register module:

mapper.registerModule(new JavaTimeModule());

See also:

Leave a Comment