intellij idea中哪个目标jvm设置优先?

laawzig2  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(418)

当使用intellij idea构建kotlin项目时,到处都有许多选项似乎在指定目标jvm版本。我已经附加了每个项目当前显示在我的项目中的值:

Settings > Build, Ex, Dep > Compiler > Kotlin Compiler > Target JVM version  (1.6)
- (above page shows warning: Following modules override project settings: MyProject.main, MyProject.test)
Settings > Build, Ex, Dep > Compiler > Java Compiler > Project bytecode version  (13)
Settings > Build, Ex, Dep > Build Tools > Gradle > Gradle JVM  (Project SDK 13)
Project Structure > Project Settings > Project > Project language level (SDK default)
Project Structure > Project Settings > Modules > [project name] > [main] > Kotlin > Target platform (JVM 1.8)
Project Structure > Project Settings > Facets > Target platform (Multiplatform)
(in build.gradle.kts file) tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "11" }

这是对我可以指定jre的各种地方的补充:

Settings > Build, Ex, Dep > Build Tools > Maven > Runner > JRE (Use Project JDK)
Project Structure > Project > Project SDK (13 java version "13.0.2")
Project Structure > Project Settings > Modules > [project name, or main, test, etc] (Project default)

以上哪项设置具有最高优先级?如果我想将我的程序编译为目标jvm版本11,那么哪个设置是必需的,并且不会被其他设置覆盖?

o2rvlv0m

o2rvlv0m1#

在基于maven的jvm项目中,要设置目标jvm版本-使用maven意味着-ide将自动选择以下设置:

<plugins>
    <plugin>    
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>11</source>
            <target>11</target>
        </configuration>
    </plugin>
</plugins>

或:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

另请参见在maven中指定java版本-属性和编译器插件之间的差异

相关问题