我在idea插件开发中使用javafx作为gui。但是通过
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("read-factory.fxml"))加载fxml文件文件时报java.lang.ClassNotFoundException: javafx.scene.layout.AnchorPane。我很奇怪,我使用纯代码是可以运行的,使用fxml就不行。
gradle设置:
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.22"
id("org.jetbrains.intellij") version "1.17.3"
id("org.openjfx.javafxplugin") version "0.1.0"
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("org.openjfx:javafx-controls:22")
implementation("org.openjfx:javafx-fxml:22")
implementation("org.openjfx:javafx-swing:22")
}
javafx {
version = "22"
modules("javafx.controls", "javafx.fxml", "javafx.media")
}
// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("2023.2.5")
type.set("IC") // Target IDE Platform
plugins.set(listOf(/* Plugin Dependencies */))
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
patchPluginXml {
sinceBuild.set("232")
untilBuild.set("242.*")
}
signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}
}
希望有java大神能解答我的疑问?
相似问题