问题描述
在使用ktor官方模版启动项目时,报错如下: 原封不动的运行 会报错
Exception in thread "main" io.ktor.server.config.HoconApplicationConfig$ReloadingException
代码片段
fun main() {
embeddedServer(Netty, port = SERVER_PORT, host = "0.0.0.0", module = Application::module)
.start(wait = true)
}
fun Application.module() {
routing {
get("/") {
call.respondText("Ktor: ${Greeting().greet()}")
}
}
}
找了一遍google 发现都是mainClass设置错了 但是我这个不一样 完全没动会报这个错 非常之抽象
解决办法
module 扩展方法加上
suspend
关键字 解决
suspend fun Application.module() {
routing {
get("/") {
call.respondText("Ktor: ${Greeting().greet()}")
}
}
}