预期的 java.lang.string,找到 kotlin.string。intellij 中的 kotlin gradle 错误

eve*_*ous 2 intellij-idea gradle gradle-kotlin-dsl

kotlin application通过gradle init --dsl kotlin-> 将项目加载到intellij 中生成了一个骨架,并收到以下错误。附上截图。

Type mismatch : inferred type is kotlin.String but java.lang.String was expected.

我已经尝试了使缓存/重启无效的各种步骤。删除 .gradle、.idea、~/.gradle 等,刷新 gradle 项目,停止 gradle 守护进程。刷新 Intellij 项目(删除 ~/.intellijIDea../system 目录)。然而,没有一个有帮助。请告诉我我还能做什么?

正如我所说,我通过gradle init --dsl kotlin. gradle 版本 5.2.1,kotlin 插件版本 1.3.20。都是最新的。intellij idea 是 2018.3 版本。对于初学者,build.gradle.kts如下所示:

plugins {
    // Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
    id("org.jetbrains.kotlin.jvm").version("1.3.20")

    // Apply the application plugin to add support for building a CLI application.
    application
}

repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // Use the Kotlin JDK 8 standard library.
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    // Use the Kotlin test library.
    testImplementation("org.jetbrains.kotlin:kotlin-test")

    // Use the Kotlin JUnit integration.
    testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

application {
    // Define the main class for the application.
    mainClassName = "info.XXX.YYY"
}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

eve*_*ous 5

在堆栈溢出时,我找到了一个链接,它通知使用 oracle jdk 而不是 openjdk。安装了 oracle jdk -> 使缓存/重启无效,为我做的。