IntelliJ:致命错误编译:无效的目标版本:1.8

Cra*_*hax 5 java intellij-idea java-8 java-runtime-compiler

我正在IntelliJ上运行Java Maven项目,并确保该项目将由Java 1.8编译。

我在“运行/调试配置”中将JRE设置为版本8 在此处输入图片说明

以及项目结构: 在此处输入图片说明 我的pom.xml文件还通过以下方式包含Java版本8:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
Run Code Online (Sandbox Code Playgroud)

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

我还将Java编译器选项设置为1.8版。在此处输入图片说明

运行项目时,出现错误:

无法在项目feed_matcher上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(默认编译):致命错误编译:无效目标版本:1.8-> [帮助1]

您知道如何解决此问题吗?

PS我遵循此链接:IDEA:javac:源发行版1.7需要目标发行版1.7,但我仍然无法解决问题。

Yai*_*sky 1

  • 确保 JAVA_HOME 设置为 JDK7 或 JRE7。以下链接对此进行了解释

  • 确保打开一个新的 shell 并运行 intellij

  • 如果这不起作用,请查看用于运行 intellij 的 idea.bat 文件 - 确保它使用 jdk7/jre7
  • 确保项目中正确定义了 JDK。查看此链接以获取更多信息。
  • 确保源在 maven 中定义为 1.7

以上4个步骤总能帮助我解决此类问题。