告诉IntelliJIdea使用特定的JDK版本,而不仅仅是JDK8,而是使用jdk-8u201

问题描述 投票:0回答:1

切换到JDK8后,MANIFEST.MF属性开始返回null https://bugs.openjdk.java.net/browse/JDK-8201636表示这是Oracle在JDK 8u151-8u172中引入的错误。

我使用pom.xml和IntelliJ IDEA。 pom.xml指定(标签<>删除)

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

IDEA设置显示target bytecode version 1.8 JAVA_HOME设置为JDK10 我安装了C:\Program Files\Java\jdk1.8.0_201

如何为构建指定此版本。 pom.xml也特朗普IDEA项目设置,反之亦然?


编辑: 我指定了

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <verbose>true</verbose>
                <fork>true</fork>
                <!--executable>{JAVA_1_8_HOME}/bin/javac</executable-->
                <executable>C:/Program Files/Java/jdk1.8.0_201/bin/javac</executable>
                <compilerVersion>1.8</compilerVersion>
            </configuration>
        </plugin>

Intellij仍然默认为JDK 1.5并且在List<String> a = new ArrayList<>();上使用“我不理解<> JDK1.5”。

intellij-idea java-8 pom.xml
1个回答
0
投票

maven.compiler.targetsource与它无关。那些只是arguments passed to javac

如果要明确指定javac的版本,可以使用the Maven Compiler Plugin

<configuration>
  <verbose>true</verbose>
  <fork>true</fork>
  <executable><!-- path-to-javac --></executable>
  <compilerVersion>1.3</compilerVersion>
</configuration>

否则,将使用Project SDK中的javac(项目结构>项目)。

© www.soinside.com 2019 - 2024. All rights reserved.