Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation error package com.fasterxml.jackson.annotation does not exist

Following class is showing issue - The import com.fasterxml.jackson cannot be resolved -

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@JsonIgnoreProperties(ignoreUnknown=true)
public class MerchantDetailsDto {

Compilation error on running clean install -

[ERROR] COMPILATION ERROR : 

[INFO] -------------------------------------------------------------

[ERROR] /Path/to/src/main/java/com/citruspay/common/dto/merchant/MerchantDetailsDto.java:[9,40] package com.fasterxml.jackson.annotation does not exist

[ERROR] /Path/to/src/main/java/com/citruspay/common/dto/merchant/MerchantDetailsDto.java:[11,2] cannot find symbol

  symbol: class JsonIgnoreProperties

The pom definition is this, which is in the pom of a project which is defined as dependency of the current project -

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

And

<jackson-core.version>2.6.1</jackson-core.version>

I checked the maven repository for this component, and it seems it does not have any dependency.

I tried changing the version to latest - 2.10.0.pr1 and tried doing maven update of the dependency project but could not find the jar downloaded inside .m2. There are two paths where the directory structure corresponding to this component is there -

.m2/fasterxml/jackson/core/jackson-annotations

.m2/repository/com/fasterxml/jackson/core/jackson-annotations

I am not sure which of these is the actual one, so I tried deleting the existing version directory from both of these, but even the same version jar did not get downloaded when I tried maven update and clean install.

Would appreciate any pointers.

Update

Output of clean install command on dependency project -

[INFO] Scanning for projects...
[INFO] 
[INFO] ------< com.project.path.to.project-dependency >------
[INFO] Building project-dependency 1.0-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ project-dependency ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ citruspay-spring-dependencies ---
[INFO] Installing /Path/to/dependency/project/pom.xml to /path to/.m2/repository/com/project/path/to/dependency/1.0-SNAPSHOT/project-dependency-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.417 s
[INFO] Finished at: 2019-07-24T17:25:42+05:30
[INFO] ------------------------------------------------------------------------
like image 663
Sandeepan Nath Avatar asked Jul 24 '19 12:07

Sandeepan Nath


2 Answers

use

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.11.0</version>
    </dependency>

This will bring in the two transitive dependencies:

like image 108
Vijay Kumar Avatar answered Nov 19 '22 08:11

Vijay Kumar


In my case I was missing below dependency.

    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-xml</artifactId>
        <version>2.13.4</version>
    </dependency>
like image 1
I AM GROOT Avatar answered Nov 19 '22 10:11

I AM GROOT