module-info – 模块未找到: com.fasterxml.jackson.core

huangapple go评论69阅读模式
英文:

module-info - module not found: com.fasterxml.jackson.core

问题

I am trying to create a module-info file for my application but getting some issues with the com.fasterxml.jackson.core module when trying to build the application:

...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
    requires com.fasterxml.jackson.core;

module-info:

module foo {
    requires org.slf4j;
    requires org.apache.commons.lang3;
    requires com.fasterxml.jackson.annotation;
    requires com.fasterxml.jackson.core;
    requires com.fasterxml.jackson.databind;
}

build.gradle:

...
dependencies {
    implementation 'org.slf4j:jcl-over-slf4j:2.0.7'

    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'

    implementation 'com.google.guava:guava:31.1-jre'

    // Logging
    implementation 'org.slf4j:slf4j-api:2.0.7'
    implementation 'org.apache.commons:commons-lang3:3.12.0'
    implementation 'commons-codec:commons-codec:1.15'

    // http tools
    api 'org.yamj:api-common:2.1'

    // testing
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:5.3.1'
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

java {
    withJavadocJar()
    withSourcesJar()
}
...

I'm using JDK 17 (Amazon Corretto) & Gradle 8.1.1

Does anyone know why this is happening and how to fix it? I've tried different versions of the jackson dependencies and still get the same issue.

If I remove

requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;

from the module-info.java, it will try to build but get errors about visibility:

...\src\main\java\foo\app.java:4: error: package com.fasterxml.jackson.databind is not visible
import com.fasterxml.jackson.databind.DeserializationFeature;
                            ^
  (package com.fasterxml.jackson.databind is declared in module com.fasterxml.jackson.databind, but module foo does not read it)
英文:

I am trying to create a module-info file for my application but getting some issues with the com.fasterxml.jackson.core module when trying to build the application:

...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
    requires com.fasterxml.jackson.core;

module-info:

module foo {
    requires org.slf4j;
    requires org.apache.commons.lang3;
    requires com.fasterxml.jackson.annotation;
    requires com.fasterxml.jackson.core;
    requires com.fasterxml.jackson.databind;
}

build.gradle:

...
dependencies {
    implementation 'org.slf4j:jcl-over-slf4j:2.0.7'

    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.15.1'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.1'

    implementation 'com.google.guava:guava:31.1-jre'

    // Logging
    implementation 'org.slf4j:slf4j-api:2.0.7'
    implementation 'org.apache.commons:commons-lang3:3.12.0'
    implementation 'commons-codec:commons-codec:1.15'

    // http tools
    api 'org.yamj:api-common:2.1'

    // testing
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:5.3.1'
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

java {
    withJavadocJar()
    withSourcesJar()
}
...

I'm using JDK 17 (Amazon Corretto) & Gradle 8.1.1

Does anyone know why this is happening and how to fix it? I've tried different versions of the jackson dependencies and still get the same issue.

If I remove

requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;

from the module-info.java, it will try to build but get errors about visibility:

...\src\main\java\foo\app.java:4: error: package com.fasterxml.jackson.databind is not visible
import com.fasterxml.jackson.databind.DeserializationFeature;
                            ^
  (package com.fasterxml.jackson.databind is declared in module com.fasterxml.jackson.databind, but module foo does not read it)

答案1

得分: 1

这是2.15.1版本中的一个额外模块信息文件1。这将在下一个版本2.15.2中修复。感谢@VGR指出,使用版本2.15.0将解决此问题,直到下一个版本发布为止。

英文:

There was an Extra module-info.class in 2.15.1. This will be fixed in the next release: 2.15.2. Thanks to @VGR for pointing out that using version 2.15.0 will fix this issue, until the next version has been released.

huangapple
  • 本文由 发表于 2023年5月18日 07:48:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276873.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定