我是模块化和现有的非模块应用。为了更容易地使用Java模块系统,我决定选择一个与我的应用程序类似的工作示例https://github.com/beryx-gist/badass-jlink-example-log4j2-javafx,并添加所需的依赖项,并使其正常工作。我从odfdom开始,我正在使用jOpenDocument处理大量的OpenDocument电子表格,但是odfdom现在看起来更有希望,所以我开始使用它。在运行该示例时,我得到以下错误:
java.lang.module.ResolutionException: Modules maven.core and maven.artifact export package org.apache.maven.artifact.repository to module org.json当我将以下行添加到buid.gradle时,就会发生这种情况。
implementation 'org.odftoolkit:odfdom-java:0.10.0'否则,项目将按预期的方式生成和运行。我该怎么解决这个问题?这是build.gradle
plugins {
id 'application'
id 'org.javamodularity.moduleplugin' version '1.8.9'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version "2.24.1"
}
repositories {
mavenCentral()
}
sourceCompatibility = "11"
targetCompatibility = "11"
dependencies {
implementation 'org.apache.logging.log4j:log4j-core:2.11.1' //automatic-module
implementation 'com.google.code.gson:gson:2.9.1' //module
implementation 'org.odftoolkit:odfdom-java:0.10.0' //none
}
javafx {
version = 16
modules = ['javafx.controls']
}
application {
mainClass = "org.openjfx.HelloFX"
mainModule = "hellofx"
}和module-info.java
module hellofx {
requires javafx.controls;
requires org.apache.logging.log4j;
exports org.openjfx;
}发布于 2022-10-23 20:15:06
我认为您可能需要将实现的模块名称“org.odfkit:odfdom-java:0.10.0”添加到module-info.java中:
requires odfdom.java;我没有得到你的错误,但得到了许多其他模块错误
.... module reads package org.apache.maven.settings from both maven.settings and maven.core我的解决方案是在我的build.gradle中添加一些排除项,以便编译:
configurations {
compileOnly.exclude group: 'xerces', module: 'xercesImpl'
// exclude from compile but allow at run time
}
implementation (group: 'org.odftoolkit', name: 'odfdom-java', version: '0.10.0') {
exclude group: 'org.apache.maven', module: 'maven-core'
exclude group: 'org.apache.maven', module: 'maven-plugin-api'
exclude group: 'io.github.git-commit-id', module: 'git-commit-id-plugin-core'
}我的build.gradle比你和我遇到的模块冲突要复杂得多,所以这不是同一个问题,但我希望这能为你指明正确的方向。
https://stackoverflow.com/questions/74038399
复制相似问题