本文介绍了如何在IntelliJ中设置'-Xuse-experimental = kotlin.experimental'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在IntelliJ中构建Kotlin/Ktor应用程序时,出现多种形式的警告

while trying to build a Kotlin/Ktor application in IntelliJ, multiple warnings of the form

Warning:(276, 6) Kotlin: This class can only be used with the compiler argument '-Xuse-experimental=kotlin.Experimental'

是输出.警告是指

@UseExperimental(KtorExperimentalLocationsAPI::class)

所以我希望通过将 Settings-> Build-> Compiler-> Kotlin Compiler->其他命令行参数设置为 -version -Xuse-experimental = kotlin. . (-版本已经存在).但是仍会生成警告.我如何满足呢?谢谢您.

so I expected to satisfy the warning by setting Settings -> Build -> Compiler -> Kotlin Compiler -> Additional command line parameters to -version -Xuse-experimental=kotlin.Experimental. (-version was already there). But the warning is still generated. How do I satisfy it? Thanks in expectation.

推荐答案

您是否在项目中使用Maven或Gradle?我在Gradle上也遇到了同样的问题,但是通过将 -Xuse-experimental = kotlin.Experimental 放在我的 build.gradle 文件中, tasks.withType .

Are you using Maven or Gradle for your project? I had the same issue with Gradle, but I was able to remove the warnings by putting the -Xuse-experimental=kotlin.Experimental in my build.gradle file, inside a tasks.withType.

对于 KtorExperimentalLocationsAPI ,您可以尝试:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=io.ktor.locations.KtorExperimentalLocationsAPI"]
}

这篇关于如何在IntelliJ中设置'-Xuse-experimental = kotlin.experimental'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-15 05:31