java.lang.UnsupportedOperationException: Kotlin 反射尚不支持包和文件外观

java.lang.UnsupportedOperationException: Packages and file facades are not yet supported in Kotlin reflection

启动基本的 Ktor 应用程序时,我得到:

Exception in thread "main" java.lang.UnsupportedOperationException: Packages and file facades are not yet supported in Kotlin reflection. Meanwhile please use Java reflection to inspect this class: class com.example.ApplicationKt
    at kotlin.reflect.jvm.internal.KClassImpl.reportUnresolvedClass(KClassImpl.kt:301)
    at kotlin.reflect.jvm.internal.KClassImpl.access$reportUnresolvedClass(KClassImpl.kt:43)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor.invoke(KClassImpl.kt:53)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$descriptor.invoke(KClassImpl.kt:44)
    at kotlin.reflect.jvm.internal.ReflectProperties$LazySoftVal.invoke(ReflectProperties.java:92)
    at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
    at kotlin.reflect.jvm.internal.KClassImpl$Data.getDescriptor(KClassImpl.kt)
    at kotlin.reflect.jvm.internal.KClassImpl$Data$objectInstance.invoke(KClassImpl.kt:106)
    at kotlin.reflect.jvm.internal.ReflectProperties$LazyVal.invoke(ReflectProperties.java:62)
    at kotlin.reflect.jvm.internal.ReflectProperties$Val.getValue(ReflectProperties.java:31)
    at kotlin.reflect.jvm.internal.KClassImpl$Data.getObjectInstance(KClassImpl.kt)
    at kotlin.reflect.jvm.internal.KClassImpl.getObjectInstance(KClassImpl.kt:239)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createModuleContainer(ApplicationEngineEnvironmentReloading.kt:328)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.executeModuleFunction(ApplicationEngineEnvironmentReloading.kt:317)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:275)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:127)
    at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:247)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:106)
    at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:18)
    at io.ktor.server.engine.ApplicationEngine$DefaultImpls.start$default(ApplicationEngine.kt:52)
    at io.ktor.server.netty.EngineMain.main(EngineMain.kt:17)
    at com.example.ApplicationKt.main(Application.kt:10)

该应用只是:

fun main(args: Array<String>): Unit = EngineMain.main(args)

fun Application.demoModule() {
    routing {
        get("/") {
            call.respondText("Hello ${call.parameters["name"]}")
        }
    }
}

我刚注意到文件 resources.application.conf 有问题。 它有错误的模块名称。我将 com.example.ApplicationKt.module 更改为 com.example.ApplicationKt.demoModule:

ktor {
    deployment {
        port = 8080
        port = ${?PORT}
    }
    application {
        modules = [ com.example.ApplicationKt.demoModule ]
    }
}

令人恼火的是,错误帮助对此只字不提。