问题描述
我无法运行gradle测试来测试spring boot javafx应用程序,运行gradle test
时出现此错误
java.lang.LayerInstantiationException: Package io.learning.dauto.test in both module io.dauto.main and module io.dauto.test
这是我的build.gradle.kts文件
plugins {
java
application
id("org.springframework.boot") version "2.3.1.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
id("org.openjfx.javafxplugin") version "0.0.9" // when I commend this,the gradle test run successfully,but I cannot test javafx
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.6.2")
testImplementation("org.testfx:testfx-junit5:4.0.16-alpha")
implementation("org.springframework.boot:spring-boot-starter")
}
plugins.withType<JavaPlugin>().configureEach {
configure<JavaPluginExtension> {
modularity.inferModulePath.set(true)
}
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_11
}
application {
mainModule.set("io.dauto.main")
mainClass.set("io.learning.dauto.MainApplication")
}
tasks.named<Test>("test") {
useJUnitPlatform()
}
我最小化的项目结构
src
|-main
|-io.learning.dauto // package
|-MainApplication.java
|-module-info.java
|-test
|-io.learning.dauto.test // package
|-FirstTest.java
|-module-info.java
build.gradle.kts
我的主要module-info.java
module io.dauto.main {
}
我的测试`module-info.java
open module io.dauto.test {
requires org.junit.jupiter.api;
requires org.testfx.junit5;
exports io.learning.dauto.test;
}
我正在使用
- 6.4级
- OpenJDK 11
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)