我试图为我的应用程序创建一个模块信息文件,但在尝试构建应用程序时,com.fasterxml.jackson.core
模块出现了一些问题:
...\src\main\java\module-info.java:5: error: module not found: com.fasterxml.jackson.core
requires com.fasterxml.jackson.core;
模块信息:
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()
}
...
我正在使用JDK 17(Amazon Corretto)和Gradle 8.1.1
有人知道为什么会发生这种情况以及如何解决它吗?我尝试了不同版本的Jackson依赖项,仍然得到相同的问题。
如果我移除
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
从module-info.java,它将尝试构建,但得到有关可见性的错误:
...\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条答案
按热度按时间kcrjzv8t1#
有一个Extra module-info.class in 2.15.1。这将在下一个版本中修复:2.15.2.感谢@VGR指出使用2.15.0版本将修复此问题,直到下一个版本发布。