首页 > 解决方案 > 在 IntellijIDEA 中编译 Kotlin:“类路径中的某些运行时 JAR 文件的版本不兼容。考虑将它们从类路径中删除”

问题描述

这是一大组可能的交互配置可能性,所以我想知道我要更改哪个。

设置:

构建成功,我成功获得了一个列表窗口。

但是,执行“重建项目”时会给出以下警告:

> Task :compileKotlin
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
    /home/rost/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.4.32/ce852b166d97f0f1991b5130c2bb02e2ef6c554e/kotlin-reflect-1.4.32.jar (version 1.4)
    /home/rost/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.61/e91d61b7cfd9a45566b580fef18bbd5c32d505b5/kotlin-stdlib-jdk8-1.3.61.jar (version 1.3)
    /home/rost/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.61/70dffc5f8ac5ea7c34f30deac5b9d8b1d48af066/kotlin-stdlib-jdk7-1.3.61.jar (version 1.3)
    /home/rost/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.32/461367948840adbb0839c51d91ed74ef4a9ccb52/kotlin-stdlib-1.4.32.jar (version 1.4)
    /home/rost/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.32/ef50bfa2c0491a11dcc35d9822edbfd6170e1ea2/kotlin-stdlib-common-1.4.32.jar (version 1.4)
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath

所以,

类路径中的某些运行时 JAR 文件的版本不兼容。考虑将它们从类路径中删除

我喜欢看到“没有警告”的情况,所以......我在哪里做这个?

我想有一些配置元素要添加到 Gradle 构建文件中(我还没有熟悉 Gradle)

构建文件现在如下:

// https://www.jetbrains.com/help/idea/javafx.html

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.32'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.32"
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.4.32"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-common:1.4.32"
}

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

dependencies {
    implementation 'no.tornado:tornadofx:1.7.20'
}

compileKotlin {
    kotlinOptions.jvmTarget = "11"
}

compileTestKotlin {
    kotlinOptions.jvmTarget = "11"
}

标签: kotlingradleintellij-idea

解决方案


推荐阅读