最近我想将Grator作为构建工具,将Ktor用于我的一个项目。
我添加了文档中提到的依赖项,但是无法在代码中使用它。 HttpClient for Ktor没有导入。 Intellisense也什么也没显示。
这是我的build.gradle文件:
ext.kotlin_version = '1.3.61'
ext.ktor_version = '1.3.2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'org.jetbrains.intellij' version '0.4.18'
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
}
group 'org.example'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'kotlin'
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "io.ktor:ktor-server-netty:1.3.2"
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2019.3.3'
alternativeIdePath "/Applications/WebStorm.app"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
patchPluginXml {
changeNotes """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}
这是我的智慧:
让我知道我在做什么错。这是一个Intellij插件项目。
您为此添加了错误的依赖项,
要获取HttpClient
,请将其添加到您的依赖项中:
implementation "io.ktor:ktor-client-core:1.3.2"
要获得不同的引擎实现,例如CIO,Netty等。阅读https://ktor.io/clients/http-client/quick-start/client.html