错误:(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)
}
}
}
答案 0 :(得分:1)
kotlinx-coroutines-core
依赖项添加到项目中
添加依赖项(您还可以添加所需的其他模块):
<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>
添加依赖项(您还可以添加所需的其他模块):
dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
}
并确保您使用最新的Kotlin版本:
buildscript {
ext.kotlin_version = '1.3.70'
}
确保存储库列表中包含jcenter()
或mavenCentral()
:
repository {
jcenter()
}