Ktor

基础入门 更改默认端口 代码配置 Application.kt 1 2 3 4 5 6 7 8 9 10 11 12 fun main() { embeddedServer( Netty, port = 8080, //更改端口 host = "0.0.0.0", module = Application::module ).start(wait = true) } fun Application.module() { configureRouting() } yaml配置 Application.kt 1 2 3 4 5 6 7 fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args) @Suppress("unused") fun Application.module() { configureRouting() } application.yaml 1 2 3 4 5 6 ktor: application: modules: - com.example.ApplicationKt.module deployment: port: 8080 添加新端点 plugins/Routing.kt ...

2024-08-09 · 4 分钟 · Nebula