13
votes

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] ------------------------------------------------------------------------
1
Is there any error while downloading dependencies (since You deleted folders in .m2)? Or does it just not download it at all? - MrHutnik
No error. Updated with output of clean install command on dependency project. - Sandeepan Nath
if You are using intellij try to synchronize (File -> Synchronize). Not sure if similar options are available (or needed) in other IDE - MrHutnik
The issue resolved for me after removing the <dependencyManagement> tag in the parent project's pom. However, I have no clear idea yet about the implications of the same. Although, the jar got downloaded and I could proceed, I am getting lots of errors in compiling dependent projects like - 'dependencies.dependency.version' for com.google.guava:guava:jar is missing - Sandeepan Nath

1 Answers

11
votes

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: