我正在使用 maven enforcer 插件来强制执行 jdk 1.7(我正在使用 java.nio.file)。由于某种原因,maven enforcer 插件无法检测到 jdk 1.7。
λ ~/ java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
λ ~/ javac -version
javac 1.7.0_13
λ ~/ mvn --version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 15:51:28+0200)
Maven home: /usr/local/Cellar/maven/3.0.5/libexec
Java version: 1.7.0_13, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.7.5", arch: "x86_64", family: "mac"
这是我在 pom.xml 中的代码 -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.7</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
这是我得到的错误 -
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-versions) @ com.microsoft.gittf.core ---
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireJavaVersion failed with message:
Detected JDK Version: 1.6.0-43 is not in the allowed range 1.7.
编辑
mvn 执行者:显示信息
显示版本 1.7 而不是 1.6...为什么强制检测 Java 版本 1.6?