看到gradle 5.0 发布,折腾 一下。
安装ktor插件,然后创建ktor工程。
玩一玩ktor
玩一玩ktor
然后跑起来

2018-11-28 09:14:59.234 [main] TRACE Application - {
    # application.conf @ file:/D:/src/demo-for-ktor/out/production/resources/application.conf: 6
    "application" : {
        # application.conf @ file:/D:/src/demo-for-ktor/out/production/resources/application.conf: 7
        "modules" : [
            # application.conf @ file:/D:/src/demo-for-ktor/out/production/resources/application.conf: 7
            "com.example.ApplicationKt.module"
        ]
    },
    # application.conf @ file:/D:/src/demo-for-ktor/out/production/resources/application.conf: 2
    "deployment" : {
        # application.conf @ file:/D:/src/demo-for-ktor/out/production/resources/application.conf: 3
        "port" : 8080
    },
    # Content hidden
    "security" : "***"
}

2018-11-28 09:15:00.842 [main] INFO  Application - No ktor.deployment.watch patterns specified, automatic reload is not active
2018-11-28 09:15:01.986 [main] INFO  Application - Responding at http://0.0.0.0:8080
2018-11-28 09:15:01.987 [main] INFO  Application - Application started: [email protected]

看到这里,也没什么特别的。启动比Spring Boot要快。
创建的工程里给的代码很简单。

fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)

@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
    install(CallLogging) {
        level = Level.INFO
        filter { call -> call.request.path().startsWith("/") }
    }

    routing {
        get("/") {
            call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain)
        }
    }
}

  • 我想要是路由稍微多点,怎么写,难道都写一个routing里?
  • http参数怎么拿?
  • cookie和session等怎么用?
  • 事务怎么做
  • 和MyBatis怎么结合?难道DAO层也用JetBrains那个?

算了,不想了,又没看完文档,想也白想。其实我比较关注,这个东西是不是性能上会有很大提升,毕竟直接上了netty。

相关文章:

  • 2021-06-07
  • 2021-10-01
  • 2021-07-10
  • 2021-04-14
  • 2021-08-22
  • 2021-12-25
  • 2021-07-28
  • 2019-11-25
猜你喜欢
  • 2021-06-21
  • 2021-10-18
  • 2021-12-14
  • 2021-04-25
  • 2020-01-16
  • 2021-12-19
  • 2021-12-16
相关资源
相似解决方案