Javafx找不到自定义模块
我正在使用OpenJDK 11的Javafx中自己的自定义库制作一个简单的电报机器人。该项目是由Intellij Idea的Javafx项目构建的,Gradle作为构建系统。该库由一个单个类(Telegram)和一个单个函数发送发送消息,并使用Jtelebot库( https ://github.com/shibme/jtelebot )。我没有安装Javafx,而是使用Intellij默认Javafx库,该库一直在以前的项目中运行良好。该程序在包含自定义库之前正确打开,但是一旦我包括它,就会出现以下错误:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module Telegram not found, required by my.group.project_telegram
有人对如何解决此问题有任何想法吗? 需要电报
包含在 module-info.java
文件中。我还尝试从头开始重新重新重新完成该项目,但没有结果。这是我的一些项目文件:
build.gradle:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.1'
}
group 'my.group'
version '1.0'
repositories {
mavenCentral()
maven {
url "https://gitlab.com/api/v4/projects/<project-id>/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = gitLabPrivateToken // the variable resides in ~/.gradle/gradle.properties
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
ext {
junitVersion = '5.8.2'
}
sourceCompatibility = '11'
targetCompatibility = '11'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
application {
mainModule = 'my.group.project_telegram'
mainClass = 'my.group.project_telegram.HelloApplication'
}
javafx {
version = '11.0.2'
modules = ['javafx.controls', 'javafx.fxml']
}
dependencies {
implementation('my.group:Telegram:1.0')
implementation('org.controlsfx:controlsfx:11.1.1')
implementation('com.dlsc.formsfx:formsfx-core:11.5.0') {
exclude(group: 'org.openjfx')
}
testImplementation("org.junit.jupiter:junit-jupiter-api:${junitVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
test {
useJUnitPlatform()
}
jlink {
imageZip = project.file("${buildDir}/distributions/app-${javafx.platform.classifier}.zip") as RegularFile
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'app'
}
}
jlinkZip {
group = 'distribution'
}
module-info.java:
module my.group.project_telegram {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
requires com.dlsc.formsfx;
requires Telegram;
opens my.group.project_telegram to javafx.fxml;
exports my.group.project_telegram;
}
库:
package pkgTelegram;
import me.shib.java.lib.telegram.bot.service.TelegramBot;
import me.shib.java.lib.telegram.bot.types.*;
import java.io.IOException;
public class Telegram {
public static void sendToTelegram(String apiToken, String chatId, String text) {
// the function's code
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些反复试验,我最终提出了解决方案。正如@Jewelsea所说,问题来自我的图书馆没有模块的事实,而只是一个课程。在 this Answer 。我最终将以下代码添加到我的库的
build.grade
:并修改了我的
module-info.java
to:}
如果您无法修改库的文件,< href =“ https://stackoverflow.com/a/51918271”>此解决方案可能会起作用,但我自己没有尝试过。
After some trial and error, I ended up coming up with a solution. As @jewelsea said, the problem came from the fact that my library did not have a module, and instead is just a single class. The is explained further in the Gradle documentation and in this answer. I ended up adding the following code to my library's
build.grade
:and modified my
module-info.java
to:}
If you can't modify your library's files, this solution might work, but I haven't tried it myself.