我有Mac OS X 10.10.3,安装了jdk 1.7和jdk 1.8。我想在1.7下编译我的项目。所以我设置了
# export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
# java -version
java version "1.7.0_72"
Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
# mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T15:57:37+04:00)
Maven home: /Public/Java/apache/apache-maven-3.3.3
Java version: 1.7.0_72, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_72.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"
我收到以下错误:
...
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project commons-amq: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
我检查了maven debug(mvn -debug
):
我看到以下输出:
[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal: org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile)
[DEBUG] Style: Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
...
<source default-value="1.5">1.8</source>
<target default-value="1.5">1.8</target>
...
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-compiler-plugin:3.3:compile' with basic configurator -->
...
[DEBUG] (f) source = 1.8
[DEBUG] (f) target = 1.8
...
我检查了POM文件,那里没有1.8规范。 <{1}}文件不存在。
那么有可能知道编译器属性config.xml
和source
的来源是什么吗?为什么在我的情况下source == target == 1.8?