Я создал следующие файлы на основе учебника здесь: https://ktor.io/quickstart/quickstart/gradle.html
Это мой kotlin файл:
package blog
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
fun Application.main() {
install(DefaultHeaders)
install(CallLogging)
install(Routing) {
get("/") {
call.respondText("My Example Blog2", ContentType.Text.Html)
}
}
}
, и это содержимое моего файла build.gradle
group 'Example'
buildscript {
ext.kotlin_version = '1.3.61'
ext.ktor_version = '1.3.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
mainClassName = 'io.ktor.server.netty.EngineMain'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "io.ktor:ktor-server-netty:$ktor_version"
compile "ch.qos.logback:logback-classic:1.2.3"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
и application.conf
ktor {
deployment {
port = 8080
}
application {
modules = [ blog.BlogAppKt.main ]
}
}
Все они находятся в одной папке.
Когда я пытался запустить сервер по этой команде ./gradlew run
, я получил это сообщение об ошибке:
> Task :run FAILED
Exception in thread "main" java.lang.IllegalArgumentException: Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt:129)
at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt)
at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:105)
at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:44)
at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:57)
at io.ktor.server.netty.EngineMain.main(EngineMain.kt:21)
Как я могу сделать application.conf
видимым для процесса Netty в этом случае?