无法访问内置声明确保您对Kotlin标准库有依赖性

时间:2019-08-22 08:00:39

标签: intellij-idea kotlin

错误:(11,40)Kotlin:无法访问内置声明     'kotlin.coroutines.SuspendFunction1'。确保您有一个     对Kotlin标准库的依赖

fun Route.coroutineHandler(fn: suspend (RoutingContext) -> Unit) {
    handler { ctx ->
        launch(ctx.vertx().dispatcher()) {
            try {
                fn(ctx)
            } catch (e: Exception) {
                ctx.fail(e)
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

Slaw一样,只需按照README

中所述将kotlinx-coroutines-core依赖项添加到项目中

Maven

添加依赖项(您还可以添加所需的其他模块):

<dependency>
    <groupId>org.jetbrains.kotlinx</groupId>
    <artifactId>kotlinx-coroutines-core</artifactId>
    <version>1.3.5</version>
</dependency>

并确保您使用最新的Kotlin版本:

<properties>
    <kotlin.version>1.3.70</kotlin.version>
</properties>

Gradle

添加依赖项(您还可以添加所需的其他模块):

dependencies {
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}

并确保您使用最新的Kotlin版本:

buildscript {
    ext.kotlin_version = '1.3.70'
}

确保存储库列表中包含jcenter()mavenCentral()

repository {
    jcenter()
}