跳至內容

Ktor/透過 exposed 串接資料庫

維基教科書,自由的教學讀本

安裝

[編輯]

build.gradle 加上以下兩段

repositories {
    mavenLocal()
    jcenter()
    maven { url 'https://kotlin.bintray.com/ktor' }
    maven { url 'https://kotlin.bintray.com/kotlin-js-wrappers' }
    maven { url "https://dl.bintray.com/kotlin/exposed" }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "io.ktor:ktor-server-netty:$ktor_version"
    implementation "ch.qos.logback:logback-classic:$logback_version"
    implementation "io.ktor:ktor-server-core:$ktor_version"
    implementation "io.ktor:ktor-client-core:$ktor_version"
    implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
    compile("org.jetbrains.exposed:exposed:0.3.2")
    implementation "io.ktor:ktor-jackson:$ktor_version"
    testImplementation "io.ktor:ktor-server-tests:$ktor_version"
}

等待自動匯入之後就可以了

使用

[編輯]

參考資料

[編輯]

https://github.com/JetBrains/Exposed/wiki