当前位置: 首页 > 知识库问答 >
问题:

生命周期配置未涵盖的插件执行:org.apache.maven.plugins:maven-tools chain-plugin:1.1:tools chain

朱承载
2023-03-14

我正在使用m2e构建一个java项目。我需要使用JAVA版本1.6。所以我正在尝试配置toolchains插件来实现它。请参阅以下链接。

https://maven.apache.org/guides/mini/guide-using-toolchains.html

但是在日食中,它抛出了下面的错误。

插件执行不包括在生命周期配置中:org.apache.maven。插件:maven toolchains插件:1.1:toolchain(执行:默认,阶段:验证)pom。xml/98 Maven项目构建生命周期映射问题

我提到了链接,但我没有得到一个适当的清晰度。下面是用于配置工具链插件的代码段。

IN 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>

共有3个答案

薛承志
2023-03-14

与其单独添加生命周期插件,还可以通过添加

<build>
    <pluginManagement>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-toolchains-plugin</artifactId>
          <version>1.1</version>
          <lifecycleMappingMetadata>
          ......................
          ......................
   </pluginManagement>
</build>

夹谷宜民
2023-03-14

更改我的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>
壤驷建德
2023-03-14

对于eclipse用户,转到窗口

从菜单中选择生命周期映射选项。默认映射文件位置可以位于eclipse临时目录中的某个位置,而不是复制文件生命周期映射元数据。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

 类似资料: