生命周期配置未涵盖的插件执行:org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
我正在使用 m2e 构建一个 java 项目。我需要使用 JAVA VERSION 1.6 。所以我正在尝试配置工具链插件来实现它。参考以下link。
https://maven.apache.org/guides/mini/guide-using-toolchains.html
但在 eclipse 中它抛出以下错误。
Plugin execution not covered by lifecycle configuration:
org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain
(execution: default, phase: validate) pom.xml /Replenishment line
98 Maven Project Build Lifecycle Mapping Problem
我提到了 link 但我没有得到适当的清晰度。下面是用于配置工具链插件的代码片段。
输入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>
和我的toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>D:\POC\jdk1.6.0_31</jdkHome>
</configuration>
</toolchain>
</toolchains>
在更改我的 pom.xml 文件后错误得到解决,如下所示。我们需要添加maven生命周期插件,然后在.
中包含元数据信息
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<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>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
不用单独添加生命周期插件,直接在<plugins>
标签前添加<pluginmanagement>
标签即可解决,如下所示
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
......................
......................
</pluginManagement>
</build>
对于 eclipse 用户,转到 Window >> 首选项 >> Maven。
Select 菜单中的生命周期映射选项。默认的映射文件位置可能在eclipse temp 目录中的某处,而不是将文件lifecycle-mapping-metadata.xml 文件复制到eclipse 目录或maven 目录中的某个位置,以便于引用。
在lifecycle-mapping-metadata.xml文件中添加以下配置。
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0.5,)</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<goals>
<goal>toolchain</goal>
</goals>
<versionRange>[0.0,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
只需执行 Maven >> 从项目视图更新项目。
这是解决问题的简单方法。
我正在使用 m2e 构建一个 java 项目。我需要使用 JAVA VERSION 1.6 。所以我正在尝试配置工具链插件来实现它。参考以下link。
https://maven.apache.org/guides/mini/guide-using-toolchains.html
但在 eclipse 中它抛出以下错误。
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-toolchains-plugin:1.1:toolchain (execution: default, phase: validate) pom.xml /Replenishment line 98 Maven Project Build Lifecycle Mapping Problem
我提到了 link 但我没有得到适当的清晰度。下面是用于配置工具链插件的代码片段。
输入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>
和我的toolchains.xml
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
<toolchain>
<type>jdk</type>
<provides>
<version>1.6</version>
<vendor>sun</vendor>
</provides>
<configuration>
<jdkHome>D:\POC\jdk1.6.0_31</jdkHome>
</configuration>
</toolchain>
</toolchains>
在更改我的 pom.xml 文件后错误得到解决,如下所示。我们需要添加maven生命周期插件,然后在.
中包含元数据信息<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>1.6</version>
<vendor>sun</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<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>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
不用单独添加生命周期插件,直接在<plugins>
标签前添加<pluginmanagement>
标签即可解决,如下所示
<build>
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<lifecycleMappingMetadata>
......................
......................
</pluginManagement>
</build>
对于 eclipse 用户,转到 Window >> 首选项 >> Maven。
Select 菜单中的生命周期映射选项。默认的映射文件位置可能在eclipse temp 目录中的某处,而不是将文件lifecycle-mapping-metadata.xml 文件复制到eclipse 目录或maven 目录中的某个位置,以便于引用。
在lifecycle-mapping-metadata.xml文件中添加以下配置。
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0.5,)</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<goals>
<goal>toolchain</goal>
</goals>
<versionRange>[0.0,)</versionRange>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
只需执行 Maven >> 从项目视图更新项目。 这是解决问题的简单方法。