0

I'm trying to do mvn clean install and I'm getting the below error. How can I resolve this, I even tried mvn clean install -U but it doesn't work at all. This is a java lib which add as a dependency for my main java project which is running in tomcat server.

package com.fasterxml.jackson.databind.annotation does not exist

My pom.xml file as below,

<properties>
    <jackson.version>2.10.0</jackson.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson</groupId>
            <artifactId>jackson-bom</artifactId>
            <version>${jackson.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <!-- Jackson -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${jackson.version}</version>
    </dependency>
</dependencies>
  • 1
    Simply add both dependencies and remove the version in your dependencies because it's already defined via the bom file... – khmarbaise Apr 28 '23 at 07:56

1 Answers1

1

You also need the jackson-databind dependency.

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

I am not sure why you are manipulating the Jackson versions. Only necessary if you do not want to use the version specified in the springboot-starter-parent. The following is sufficient to use the spring recommended Jackson version. Note no version mentioned:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
</dependency>

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

If you need to use another version of Jackson all you need is the following:

<properties>
    <jackson.version>2.10.0</jackson.version>
</properties>
John Williams
  • 4,252
  • 2
  • 9
  • 18
  • 1
    Nobody ever said this was a Spring or Spring Boot project. The only thing the question states is that it's an application running in Tomcat. – Rob Spoor Apr 28 '23 at 10:54