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

标签 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)
            }
        }
    }

最佳答案

点赞Slaw评论只需添加 kotlinx-coroutines-coreREADME 中所述,对您的项目的依赖关系

马文

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

<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()
}

关于intellij-idea - 无法访问内置声明确保您对 Kotlin 标准库有依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57604665/

相关文章:

android - 带有 Dao 和通用 Result 类的协程流

android - 为什么我的构建在 Android Studio 中失败并出现异常 "Failed to find byte code for android/support/v7/app/ActionBarActivity"?

scala - 为什么相同的 Scala 代码在命令行中可以正常工作,而在 Intellij 中却不行?

grails - 如何将 grails 项目导入 Intellij 13.1 IDEA?

Android - Jetpack 撰写缺少的引用

java - kotlin - 平台类型/方法的非空标记

java - IntelliJ - 模块 xx 是从 Maven 导入的。重新导入后对其配置所做的任何更改都可能丢失意味着什么?

java - IntelliJ - 无法解析符号 'Arrays'

kotlin - 为什么 Kotlin lang 只允许项目中的单个主要功能?

kotlin - android jetpack compose 中带有 ConstraintLayout 的 LazyColumn