我正在使用Time4J 库的波斯日历选择器。
当我运行应用程序时,./gradlew run
我看到它正在运行。但是,当我启动使用Badass JLink Plugin构建的应用程序的 JavaFX 运行时映像时,我收到此错误:
Caused by: java.util.ServiceConfigurationError: net.time4j.engine.ChronoExtension: module alif.pooya.merged.module does not declare `uses`
at java.base/java.util.ServiceLoader.fail(Unknown Source)
at java.base/java.util.ServiceLoader.checkCaller(Unknown Source)
at java.base/java.util.ServiceLoader.<init>(Unknown Source)
at java.base/java.util.ServiceLoader.load(Unknown Source)
at alif.pooya.merged.module@1.0-SNAPSHOT/net.time4j.base.ResourceLoader$StdResourceLoader.services(Unknown Source)
at alif.pooya.merged.module@1.0-SNAPSHOT/net.time4j.PlainDate.registerExtensions(Unknown Source)
at alif.pooya.merged.module@1.0-SNAPSHOT/net.time4j.PlainDate.<clinit>(Unknown Source)
at alif.pooya.merged.module@1.0-SNAPSHOT/net.time4j.tz.repo.TimezoneRepositoryProviderSPI.<init>(Unknown Source)
at alif.pooya.merged.module@1.0-SNAPSHOT/net.time4j.tz.repo.TZDATA.init(Unknown Source)
at alif_chat_desktop@1.0-SNAPSHOT/main.MainApp.start(Unknown Source)
从这个屏幕截图中可以看出,实际的应用程序本身适用于/.gradlew run
:
但是,当尝试使用 启动 jlink 生成的运行时映像时 {%project.dir%}/build/image/bin/AlifDesktop
,出现错误。
这就是我创建波斯日历选择器的方式:
TZDATA.init();
CalendarPicker<PersianCalendar> picker = CalendarPicker.persianWithSystemDefaults();
picker.setLengthOfAnimations(Duration.seconds(0.3));
picker.setShowInfoLabel(true);
picker.setLocale(new Locale("fa", "IR"));
picker.setShowWeeks(true);
picker.setCellCustomizer(
(cell, column, row, model, date) -> {
if (CellCustomizer.isWeekend(column, model)) {
cell.setStyle("-fx-background-color: #FFE0E0;");
cell.setDisable(false);
}
}
);
我也将它用于 build.gradle:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.9'
id 'org.beryx.jlink' version '2.21.4'
}
group 'alif.pooya'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
}
javafx {
version = "15"
modules = ['javafx.base', 'javafx.graphics', 'javafx.controls', 'javafx.web','javafx.fxml']
}
dependencies {
compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.7.2'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
compile group: 'org.java-websocket', name: 'Java-WebSocket', version: '1.5.1'
compile group: 'com.jfoenix', name: 'jfoenix', version: '9.0.8'
compile group: 'net.time4j', name: 'time4j-ui', version: '5.7'
compile group: 'net.time4j', name: 'time4j-tzdata', version: '5.0-2020a'
}
mainClassName = "$moduleName/main.MainApp"
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'AlifChatDesktop'
jvmArgs = [
'-Dnet.time4j.base.useClassloaderOnly=true'
]
}
addExtraDependencies("javafx")
}
这是我的模块信息.java:
module alif_chat_desktop {
requires javafx.controls;
requires javafx.fxml;
requires okhttp3;
requires okio.jvm;
requires kotlin.stdlib.common;
requires annotations;
requires Java.WebSocket;
requires com.jfoenix;
requires com.google.gson;
requires slf4j.api;
requires net.time4j.base;
requires net.time4j.ui;
requires net.time4j.tzdb;
opens main to javafx.fxml;
exports main;
}