【问题标题】:Strange exception thrown in KtorKtor 中抛出的奇怪异常
【发布时间】:2020-09-21 22:08:53
【问题描述】:

今天我在 Ktor 中遇到了一个奇怪的状态页面异常。

我正在尝试使用 ktor 构建一个简单的 api,并且我做了这条路线:

fun Route.phrase(db : Repository){
post(PHRASE_ENDPOINT){
    val request = call.receive<Request>()
    val phrase = db.add(EmojiPhrase(request.toString(), request.toString()))
    this.call.respond(phrase)
   }}

当我尝试发送我得到的请求时 java.lang.ClassNotFoundException: kotlinx.coroutines.io.ByteReadChannel

有人遇到过这个问题

我正在使用:

    ktor_version=1.3.2, 
    kotlin_version=1.4.10, 
    moshi_version= 1.0.1

【问题讨论】:

    标签: kotlin ktor


    【解决方案1】:

    问题似乎出在 moshi 转换器中:https://github.com/rharter/ktor-moshi/issues/7#issuecomment-580977097

    在 PR 被合并之前,你可以通过以下方式使用补丁版本 jitpack

    buildscript {
        repositories {
            jcenter()
            maven { url 'https://jitpack.io' }
        }
    }
    dependencies {
        implementation 'com.github.cs125-illinois:ktor-moshi:7252ca49ed'
    }
    

    【讨论】:

      猜你喜欢
      • 2010-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多