0

我正在使用 MySQL 数据库 (AWS) 开发 JavaFX 项目。当我从 Intellij 启动我的项目时,它运行良好,但是当我尝试使用 jpackage 和 build.gradle 导出、安装和启动我的应用程序时,我得到一个带有以下错误的窗口:

com.mysql.cj.jdbc.exceptions.communicationsexception communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The drive has not received any packets from server.

我不明白问题出在哪里。所有连接都通过 AWS 授权到我的数据库,jpackage 进程运行没有错误,正如我之前所说,当我从 IntelliJ 启动时它可以完美运行。

这是我的 build.gradle

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.9'
    id 'org.beryx.runtime' version '1.11.3'
}

group 'org.example'
version '0.0.1'

repositories {
    mavenCentral()
}

javafx {
    version = "15.0.1"
    modules = [ 'javafx.controls','javafx.fxml' ]
}
jar {
    manifest {
        attributes 'Main-Class': 'com.github.studeasy.launcher.appMain'
    }
}

application {
    mainClassName= "com.github.studeasy.launcher.appMain"
    applicationName = 'StudEasy'
}


javadoc {
    source = sourceSets.main.allJava
    classpath = sourceSets.main.runtimeClasspath
}

test {
    useJUnitPlatform()
}

runtime {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        noConsole = false
    }
    jpackage {
        def currentOs = org.gradle.internal.os.OperatingSystem.current()
        def imgType = currentOs.windows ? 'ico' : currentOs.macOsX ? 'icns' : 'png'
        imageOptions += ['--icon', "src/main/resources/images/logo.$imgType"]
        installerOptions += ['--resource-dir', "src/main/resources"]
        installerOptions += ['--vendor', 'Stud Easy']
        if(currentOs.windows) {
            installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-shortcut']
        }
        else if (currentOs.linux) {
            installerOptions += ['--linux-package-name', 'StudEasy','--linux-shortcut']
        }
        else if (currentOs.macOsX) {
            installerOptions += ['--mac-package-name', 'StudEasy']
        }
    }
}
dependencies {

    implementation "mysql:mysql-connector-java:8.0.22"
    runtime "mysql:mysql-connector-java:8.0.22"
    implementation group: 'javax.mail', name: 'mail', version: '1.4'

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
    testImplementation  group: 'org.mockito', name: 'mockito-core', version: '3.6.28'
    testImplementation  group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.6.28'
    testImplementation group: 'org.springframework', name: 'spring-test', version: '5.3.2'

}
 

预先感谢您的帮助

4

0 回答 0