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

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

问题描述

我是Maven和IntelliJ IDEA的新手。

I'm new to both Maven and IntelliJ IDEA.

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

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 Community Edition 13.1.2。

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

推荐答案

或者更容易,将其添加到您的pom的属性部分:

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天全站免登陆