【问题标题】:Including javafx.util.Pair as a dependency in gradle在 gradle 中包含 javafx.util.Pair 作为依赖项
【发布时间】:2018-08-03 00:11:07
【问题描述】:

我有一个使用 oracle JDK 开发的 springboot 应用程序,它使用 javafx.util.pair 类。当构建的 jar 在具有 OpenJDK 的系统上运行时,它找不到此类。我如何用我的 jar 打包这个依赖项?我正在使用gradle。这是我的 build.gradle 文件

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE")
    }
}

description = "CF Service Broker using Java / Spring"

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

jar {
    baseName = 'cf-tile'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8


dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-devtools")
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('com.jayway.jsonpath:json-path')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

【问题讨论】:

  • 是否值得将所有 JavaFX 引入您的项目中,只为那一类?一个类不仅可以从头开始实现,而且对于几乎所有用例来说,它应该是一个有意义的类,它描述了它的两个值实际代表什么?
  • @vgr 我同意。我已经按照你的建议做了。但仅出于学术目的,我想知道是否有可能(尤其是仅包括该类及其依赖项......而不是整个 JavaFX 包)

标签: java spring-boot gradle javafx dependencies


【解决方案1】:

我不相信您可以通过 gradle 导入 javafx utils,但对于未将其包含在其 OpenJDK 版本中的平台,您可以使用 openjfx。

例如,您可以在 ubuntu 中使用:

sudo apt-get install openjfx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    相关资源
    最近更新 更多