gradle - 预期 java.lang.string,找到 kotlin.string。intellij中的kotlin gradle错误
问题描述
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"
}
解决方案
在堆栈溢出时,我登陆了一个链接,它通知使用 oracle jdk 而不是 openjdk。安装了 oracle jdk -> 使缓存/重启无效,为我做了。
推荐阅读
- android - 永久模糊更改位图
- reactjs - ReactJS fetchAPI JSON 类型 - TypeError:content.forEach 不是函数
- css - 为什么在 Vue 组件的样式中添加 lang=less 会改变现有行为?
- memory - JVM 已用内存与实际堆内存差异很大(G1GC)
- azure-devops - VSTS Microsoft 托管代理:虚拟机大小
- ios - iOS 状态栏变色动画
- javascript - 奇怪的javascript行为(将循环分配给变量?)
- ajax - GET http://localhost:8005/context.blade.php 404(未找到)
- html - 如何设置表格td的底线
- powershell - 重新安装 Internet Explorer 11