我正在使用 m2e 构建一个 java 项目。我需要使用JAVA 版本 1.6。所以我正在尝试配置工具链插件来实现它。通过参考下面的链接。
https://maven.apache.org/guides/mini/guide-using-toolchains.html
但在 Eclipse 中它抛出以下错误。
生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (execution:default,phase:validate)pom.xml/Replenishment line 98 Maven项目构建生命周期映射问题
我引用了该链接 ,但我没有得到适当的清晰度。下面是用于配置工具链插件的代码片段。
在 pom.XML 中
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-toolchains-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>toolchain</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
和我的 toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides> …
Run Code Online (Sandbox Code Playgroud) 我在 CentOS Linux 版本 7.3.1611 服务器上使用 Jenkins 版本 2.73-1.1。
服务器上有3个不同版本的JDK:
[root @ jenkins java] # ll
total 12
lrwxrwxrwx. 1 root root 16 27 Apr 16.25 default -> / usr / java / latest
drwxr-xr-x. 8 root root 4096 27 Mar 2013 jdk1.6.0_45
drwxr-xr-x. Root root 4096 11 Apr 2015 jdk1.7.0_80
drwxr-xr-x. 9 root root 4096 27 Apr 16.25 jdk1.8.0_131
lrwxrwxrwx. 1 root root 22 27 apr 16.25 latest -> /usr/java/jdk1.8.0_131
Run Code Online (Sandbox Code Playgroud)
如下图所示,Jenkins使用的是jdk1.8.0_131版本,在我的项目中我指定使用JDK7。
当我尝试编译我的项目 ( …