我在 IntelliJ 中設定了一個基本的 JavaFX 專案:

該專案使用 Gradle 進行依賴管理。我添加的依賴項是 javax.mail.api,您可以在此處的 build.gradle 檔案中看到:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'org.beryx.jlink' version '2.25.0'
}
group 'com.contoso'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
junitVersion = '5.9.0'
}
sourceCompatibility = '18'
targetCompatibility = '18'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'com.contoso.portwatcher'
mainClass = 'com.contoso.portwatcher.Application'
}
javafx {
version = '18.0.1'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
implementation group: 'javax.mail', name: 'javax.mail-api', version: '1.6.2'
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip")
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
我現在遇到的問題是,當嘗試使用以下運行配置執行編程時:

我得到以下例外:

module-info.java 檔案指定了添加的依賴模塊:
module com.contoso.portwatcher {
requires javafx.controls;
requires javafx.fxml;
requires javax.mail.api;
opens com.contoso.portwatcher to javafx.fxml;
exports com.contoso.portwatcher;
}
我的問題是為什么找不到模塊?
感謝您的耐心和幫助。
uj5u.com熱心網友回復:
您的依賴項中的郵件 API jar未定義module-info.class.
新的Jakarta 郵件API 確實定義了該檔案。將您的使用遷移javax.mail到jakarta.mail軟體包并使用更新的工件,然后應該可以作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/526355.html
標籤:爪哇毕业典礼javafx
上一篇:問題動態初始化select2
