错误:java:javacTask:源版本 8 需要目标版本 1.8 [英] Error:java: javacTask: source release 8 requires target release 1.8

查看:31
本文介绍了错误:java:javacTask:源版本 8 需要目标版本 1.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 IntelliJ IDE 无法编译任何项目.以下设置截图:

Using IntelliJ IDE can't compile any projects. Screenshots of settings below:

使用的JDK:

项目 SDK 和语言级别:

Project SDK and Language level:

语言水平:

有人有什么想法吗?

推荐答案

  1. 转到文件>设置 >构建、执行、部署 >编译器Java 编译器 如果在 Mac 上,则在 Intellij IDEA > 下首选项... >构建、执行、部署 >Java 编译器
  2. 目标字节码版本更改为您正在使用的模块的1.8.
  1. Go to File > Settings > Build, Execution, Deployment > Compiler > Java Compiler If on a Mac, it's under Intellij IDEA > Preferences... > Build, Execution, Deployment > Java Compiler
  2. Change Target bytecode version to 1.8 of the module that you are working for.

如果您使用的是 Maven

在顶级project节点下的pom.xml中添加编译器插件:

Add the compiler plugin to pom.xml under the top-level project node:

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

(从评论中提升.)

注意:如果您不介意重新导入您的项目,那么您唯一真正需要做的就是更改 pom 并重新导入项目,然后 IntelliJ 会选择正确的设置,您不必手动更改

Note: If you don't mind reimporting your project, then the only thing you really need to do is change the pom and reimport the project, then IntelliJ will pick up the correct settings and you don't have to manually change them.

这篇关于错误:java:javacTask:源版本 8 需要目标版本 1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆