Problem with deserialization of LocalDateTime in Junit test

后端 未结 1 944
南旧
南旧 2020-11-30 12:59

I have problems LocalDateTime deserialization in Junit test. I have simple REST API which returns some DTO object. When I

相关标签:
1条回答
  • 2020-11-30 13:44

    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:

    • jackson-modules-java8
    0 讨论(0)
提交回复
热议问题