0

自从将我们的 JavaFX 应用程序更新到 JDK 16、openjfx 16 和 gradle 7.1.1 后,我们一直遇到无法通过标准 IntelliJ 行断点调试程序的问题。

但是由于某种原因,我们能够命中异常断点。

相关依赖

  • JDK 16.0.1
  • 开放JFX 16
  • Gradle 7.1.1(使用项目 JDK 16.0.1)
  • 春季启动 2.5.2

IntelliJ 运行配置,使用 Spring Boot 的bootRun,标记了以下 gradle 调试复选框:

  • 启用 Gradle 脚本调试
  • 在同一会话中调试分叉任务

尝试过的事情

  1. 将 JDK 降级到 JDK 11
  2. 将 Gradle 降级到 6.9
  3. 将 Spring Boot 降级到 2.2.2.RELEASE
  4. 在 IntelliJ gradle 运行配置中尝试不同的 Gradle 调试选项

我们 build.gradle 的相关部分

plugins {
    id 'java'
    id 'application'
    id 'org.springframework.boot' version '2.5.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'org.openjfx.javafxplugin' version '0.0.10'
    id 'org.beryx.jlink' version '2.24.0'
}

group 'com.example'
version '2.0'

sourceCompatibility = 16
targetCompatibility = 16

mainClassName = 'com.example.frontend.MainLauncher'

java {
    modularity.inferModulePath.set(true)
}

javafx {
    version = "16"
    modules = [
            'javafx.controls',
            'javafx.fxml',
            'javafx.graphics'
    ]
}

ext {
    typesafeConfigVersion = '1.3.1'
    jacksonVersion = '2.10.1'
    lombokVersion = '1.18.20'
    ikonliVersion = '12.2.0'
}

def jvmOptions = [
        "-XX:+UseShenandoahGC", "-XX:+UseStringDeduplication",
        //Limit the JVM memory usage
        "-Xmx1024m",
        "-Xms256m",
]

jlink {
    addOptions '--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'
    launcher {
        name = 'Heutinck Desktop Client'
        mainClass.set('com.example.frontend.MainLauncher')
        jvmArgs += jvmOptions
    }
    mergedModule {
        additive = true
    }
    forceMerge 'jackson', 'log4j-api', 'javafx', 'classmate'
}

sourceSets.main.resources {
    srcDirs { 'src/main/resources/config' }
    srcDirs("src/main/java").includes.addAll(["**/*.fxml", "**/*.css", "**/*.properties", "**/*.conf", "**/*.png", "**/*.yml"])
}

springBoot {
    mainClass.set('com.example.frontend.MainLauncher')
}

bootRun {
    doFirst {
        jvmArgs   =   [
                '--module-path', classpath.asPath,
                '--add-modules', 'javafx.controls',
                '--add-modules', 'javafx.fxml',
                '--add-modules', 'javafx.graphics',
        ]
        jvmArgs += jvmOptions
        systemProperties = System.properties
    }
}

tasks.register("bootRunDev") {
    group = "application"
    description = "Runs the Spring Boot application with the dev profile"
    doFirst {
        tasks.bootRun.configure {
            System.properties.setProperty("spring.profiles.active", "dev")
        }
    }
    finalizedBy("bootRun")
}

repositories {
    mavenCentral()
}

dependencies {
    annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
    compileOnly "org.projectlombok:lombok:${lombokVersion}"
    testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
    testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"

    compileOnly 'net.jcip:jcip-annotations:1.0'

    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
    implementation 'com.fasterxml.jackson.core:jackson-databind'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310'
    implementation 'com.dlsc.afterburner:afterburner.fx:2.1.0'

    //Spring
    implementation('org.springframework.boot:spring-boot-starter-security') {
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }
    implementation 'javax.servlet:javax.servlet-api:4.0.1'

    //JavaFX
    implementation "com.typesafe:config:${typesafeConfigVersion}"
    implementation 'org.controlsfx:controlsfx:11.1.0'
    implementation('io.github.palexdev:materialfx:11.11.1') {
        exclude group: 'org.openjfx'
    }
    implementation 'org.reactfx:reactfx:2.0-M5'
    implementation "org.kordamp.ikonli:ikonli-javafx:${ikonliVersion}"
    implementation "org.kordamp.ikonli:ikonli-materialdesign-pack:${ikonliVersion}"

    implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
    implementation group: 'org.apache.poi', name: 'poi', version: '3.17'

    implementation 'io.projectreactor.tools:blockhound:1.0.6.RELEASE'

    testImplementation 'junit:junit:4+'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation('org.springframework.security:spring-security-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

4

0 回答 0