项目编译报错release 8 requires target 1.8 release

project compile error release 8 requires target 1.8 release

我有一个错误 Error:java: javacTask: source release 8 requires target release 1.8。我使用 1.8 java,语言级别设置为 8。我猜唯一可能的原因是 pom.xml 文件中的行

         <configuration>
               <executable>${java.home}/bin/java</executable>
               <commandlineArgs>${runfx.args}</commandlineArgs>
         </configuration>

这里是行

 <commandlineArgs>${runfx.args}</commandlineArgs>

是红色的,我不知道该怎么办。

要在 Maven 中设置编译器版本,您的 pom.xml 文件中应该有如下内容:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

3.3 是最新的 Maven Compiler Plugin 版本。我假设 Java 8 支持需要它。

这是same as setting the -source and -target compiler options