5

import com.fasterxml.jackson.datatype cannot be resolved

As the screen shot shows, import com.fasterxml.jackson.datatype cannot be resolved.

I have imported jackson-datatype-jsr310', version: '2.9.3 in the build.gradle like this,

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.linkedin.learning'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('com.h2database:h2')
    testCompile('org.springframework.boot:spring-boot-starter-test')

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.3'


}

The last a few lines are from the Maven Repo: https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.9.3

What I am trying to use is the

com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

However, even the com.fasterxml.jackson.datatype cannot be imported properly.

To solve this problem, I tried to add more dependencies in build.gradle, as this post suggests

Jackson cannot access com.fasterxml.jackson.core.ObjectCodec

buildscript {
    ext {
        springBootVersion = '1.5.9.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.linkedin.learning'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    runtime('com.h2database:h2')
    testCompile('org.springframework.boot:spring-boot-starter-test')

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.9.3'


    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.9.3'

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.module/jackson-module-parameter-names
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.3'

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.9.3'

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jsr310
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.3'

}

But it is still not imported.

The IDE I am using is Spring Tool Suite, and it is a web application

Thanks!

EDIT:

I understand that jackson-datatype-jsr310 is DEPRECATED and has become part of Jackson Java 8 Modules as of Jackson 2.8.5.

https://github.com/FasterXML/jackson-datatype-jsr310

However, I add this to the end of build.gradle,

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.9.3'

And import this

import com.fasterxml.jackson.datatype.jdk8;

It still shows import com.fasterxml.jackson.datatype cannot be resolved.

enter image description here

Amir Azizkhani
  • 1,662
  • 17
  • 30
  • is your IDE updating at all? Maybe you need to manually update or set automatic updates. – tkruse Dec 25 '17 at 02:25
  • @tkruse Hi, I updated the IDE but the problem is still there. I think it has something to do with the fasterxml.jackson.datatype. Can you check it out? Thanks! – JustAnotherJavaDeveloper Dec 26 '17 at 04:51
  • 1
    Your buildscripts are fine on the command line. Both first and second version. FOr both, I could compile a simple Java file importing `com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;`. It seems you messed up your IDE setup, and nobody can help you. Probably best delete the project from your IDE and start over. – tkruse Dec 26 '17 at 07:57

0 Answers0