Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find artifact Jackson-modules-java8:jar

I use open-jdk-10.

mvn clean install

Could not find artifact com.fasterxml.jackson.module:jackson-modules-java8:jar:2.9.8 in" central"

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>group</groupId>
    <artifactId>artifact</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>10</maven.compiler.source>
        <maven.compiler.target>10</maven.compiler.target>
        <jackson.version>2.9.8</jackson.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-modules-java8</artifactId>
            <version>${jackson.version}</version>
        </dependency>
    </dependencies>

</project>

without jackson-modules-java8 it builds successfully.

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-modules-java8</artifactId>
    <version>${jackson.version}</version>
</dependency>

There is a similar question, but it does not solve my problem. I have maven dependency in my pom file. Downloading things manually is the last thing I will do if nothing else works.

like image 991
Yan Khonski Avatar asked Mar 05 '23 11:03

Yan Khonski


2 Answers

On GitHub jackson-datatype-jsr310 page you can read:

(DEPRECATED) -- moved under jackson-modules-java8 repo: https://github.com/FasterXML/jackson-modules-java8

On linked page you can find info about java8 module:

Note that the parent project -- jackson-modules-java8 -- is ONLY used as parent pom by individual "child" modules, and DOES NOT have dependencies on them.

and how new modules should be used:

<dependency>
    <groupId>com.fasterxml.jackson.module</groupId>
    <artifactId>jackson-module-parameter-names</artifactId>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

Links to Maven Repositories:

  1. jackson-datatype-jdk8
  2. All com.fasterxml.jackson.datatype modules
like image 60
Michał Ziober Avatar answered Mar 08 '23 12:03

Michał Ziober


I removed java8-module.

I use instead

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-jsr310</artifactId>
    <version>${jackson.version}</version>
</dependency>

I do not know what the difference is between jackson-modules-java8 and jackson-datatype-jsr310, but the latter works for me.

When you create an object mapper, register JavaTimeModule.

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
like image 32
Yan Khonski Avatar answered Mar 08 '23 13:03

Yan Khonski