JAVA_HOME 版本的 Maven 没有 运行,为什么?
Maven doesn't run with the JAVA_HOME version, why?
我已经安装了 maven 3 和 java 8,尽管当我 运行 mvn clean install maven 失败时。
这是 mvn -v 的输出:
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T20:10:27+00:00)
Maven home: /usr/local/Cellar/maven/3.3.1/libexec
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"
猫的输出~/.bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
alias java_jre='/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'
maven 抛出错误:
INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/DivSum.java:[12,57] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/Test.java:[9,49] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.049 s
[INFO] Finished at: 2015-03-28T23:56:56+00:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project topcoder: Compilation failure: Compilation failure:
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/DivSum.java:[12,57] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/Test.java:[9,49] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
有什么我想念的吗?
maven 正在尝试将您的源代码编译为 1.5 字节码,但遇到了使用 1.7 功能(特别是菱形运算符)编写的代码。因为你有 1.8 JDK 你可以设置你的 Maven 编译属性如下:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
<maven.compiler.testSource>1.8</maven.compiler.testSource>
</properties>
我已经安装了 maven 3 和 java 8,尽管当我 运行 mvn clean install maven 失败时。
这是 mvn -v 的输出:
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T20:10:27+00:00)
Maven home: /usr/local/Cellar/maven/3.3.1/libexec
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"
猫的输出~/.bash_profile:
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
alias java_jre='/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java'
maven 抛出错误:
INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/DivSum.java:[12,57] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/Test.java:[9,49] diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.049 s
[INFO] Finished at: 2015-03-28T23:56:56+00:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project topcoder: Compilation failure: Compilation failure:
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/DivSum.java:[12,57] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
[ERROR] /Users/orestis/Documents/AlgorithmsRepo/algorithmicProblems/src/main/java/com/spoj/Test.java:[9,49] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)
有什么我想念的吗?
maven 正在尝试将您的源代码编译为 1.5 字节码,但遇到了使用 1.7 功能(特别是菱形运算符)编写的代码。因为你有 1.8 JDK 你可以设置你的 Maven 编译属性如下:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.testTarget>1.8</maven.compiler.testTarget>
<maven.compiler.testSource>1.8</maven.compiler.testSource>
</properties>