如何在 IntelliJ 中更改 Maven 的 Java 版本? [英] How to change Java version for Maven in IntelliJ?

查看:27
本文介绍了如何在 IntelliJ 中更改 Maven 的 Java 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Maven 和 IntelliJ IDEA 的新手.

I'm new to both Maven and IntelliJ IDEA.

我有一个用 Java 8 编写的 Maven 项目.每当我尝试构建它时(Maven 项目窗口 -> 生命周期 -> 编译 -> 运行 Maven 构建),我都会收到一系列编译错误:

I have a Maven project written in Java 8. Whenever I try to build it (Maven Projects window -> Lifecycle -> compile -> Run Maven Build) I get a series of compilation errors:

[ERROR] path/to/file.java:[26,52] lambda expressions are not supported in -source 1.5
(use -source 8 or higher to enable lambda expressions)

我应该在哪里更改 -source 参数的值?我尝试在 Settings -> Compiler -> Java Compiler 中将其添加为附加参数,但得到了相同的结果.

Where am I supposed to change the value of the -source parameter? I tried adding it as an additional parameter in Settings -> Compiler - > Java Compiler, but I got the same results.

项目和模块的语言级别都设置为 8.0.

The project's and module's language levels are both set to 8.0.

我使用的是 Maven 3.2.3 和 IntelliJ IDEA 社区版 13.1.2.

I'm using Maven 3.2.3 and IntelliJ IDEA Community Edition 13.1.2.

推荐答案

或者更简单,将此添加到您的 pom 的 properties 部分:

Or easier, add this to your pom's properties section:

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

这篇关于如何在 IntelliJ 中更改 Maven 的 Java 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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