我使用maven執行者插件只強制執行jdk 1.7(我正在使用java.nio.file)。 出於某種原因,maven執行者插件無法檢測到jdk 1.7。Maven執行者不檢測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執行者:display-info
顯示版本1.7而不是1.6 ...爲什麼執行檢測到java版本1.6?
你的機器上有多個JDK嗎?請同時發佈maven-compiler-plugin的配置。 –
運行mvn執行者:display-info在應用 MrTinkz解決方案後解決了它。 – ronnyfm