javajacksonjackson-databindjackson-modules

Jackson JavaTimeModule not found even after adding jackson-modules-java8 dependency?


NOT A DUPLICATE -- I'm trying to follow the solutions given in Is there a jackson datatype module for JDK8 java.time? (it is the cause of this question, not a duplicate).

I added

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-modules-java8</artifactId>
    <version>2.9.5</version>
    <type>pom</type>
</dependency>

But I'm still not able to do this:

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());

The JavaTimeModule class is nowhere to be found. What am I doing wrong?


Solution

  • Use the following dependency:

    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
        <version>2.9.5</version>
    </dependency>
    

    Then you'll be able to register the JavaTimeModule class. See the documentation for details.