[英]Maven compilation of my Java 8 source code fails
On my mac, I am trying to compile some Java 8 source code I wrote. 在我的Mac上,我正在尝试编译我编写的一些Java 8源代码。 It compiles fine in Eclipse, but in Maven, the compilation is failing.
它在Eclipse中编译良好,但是在Maven中,编译失败。
I get multiple errors of the form: 我收到以下形式的多个错误:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/admin/eclipse/workspaces/default/Java8/src/main/java/language/utilities/MapDemo.java:[14,33] lambda expressions are not supported in -source 1.7
(use -source 8 or higher to enable lambda expressions)
Running mvn -v yields: 运行mvn -v将产生:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /Users/admin/apache-maven-3.3.9
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
Default locale: en_IE, platform encoding: UTF-8
OS name: "mac os x", version: "10.12", arch: "x86_64", family: "mac"
Running the export command shows that the JAVA_HOME variable is set to: 运行export命令显示JAVA_HOME变量设置为:
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home"
What is this '-source' property? 什么是“-源”属性? Why do I need to set it if my Java version is Java 8?
如果我的Java版本是Java 8,为什么需要设置它?
Set 组
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
in the properties of your pom . 在pom的属性中 。
You should not set this in the settings.xml
because you force other people to change their settings.xml
and use JDK8 in all of their other projects by default! 您不应在
settings.xml
中进行settings.xml
因为默认情况下您会强迫其他人更改其settings.xml
并在其所有其他项目中使用JDK8!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.