如何在pom.xml中修复m2e错误:生命周期配置不包含插件执行?

时间:2022-01-10 10:39:35

I am having the title mentioned error in my Maven Java project. Below is a comparison of a good project and my troubled project. 如何在pom.xml中修复m2e错误:生命周期配置不包含插件执行?

我在Maven Java项目中有标题提到的错误。下面是一个好项目和我的问题项目的比较。

  • How to fix these 2 errors?
  • 如何解决这2个错误?
  • And in the upper good one why there're so many configurator, configurator,...? It looks weird even if there are no error marks.
  • 而在上层好的为什么有这么多的配置器,配置器,...?即使没有错误标记,它看起来也很奇怪。

I have read the thread: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds.

我已经阅读了线程:如何解决Spring Data Maven Builds的“生命周期配置未涵盖的插件执行”。

But it doesn't provide a clean shot. It's full of explanations but without canonical solutions.

但它没有提供干净的镜头。它充满了解释,但没有规范的解决方案。

BTW, I am so frustrated by the Maven XML mess that I have to find some alternative.

顺便说一句,我对Maven XML混乱感到非常沮丧,我必须找到一些替代方案。

ADD 1 -- issue partially fixed, but not sure about root cause, and the so many configurators.

OK, I noticed in the Installation Details of eclipse, there's no m2e items. Strange how can I import maven projects without installing it. Anyway I install the latest 1.6.2 from http://www.eclipse.org/m2e/. And the above issue is gone. But this is just a solution. I still don't know why there're so many configurator...

好的,我注意到在Eclipse的安装细节中,没有m2e项目。奇怪的是如何在不安装的情况下导入maven项目。无论如何,我从http://www.eclipse.org/m2e/安装最新的1.6.2。而上述问题已经消失。但这只是一个解决方案。我还是不知道为什么会有这么多配置器......

ADD 2 -- add my pom.xml, it is not the effective pom.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.its</groupId>
    <artifactId>cloud</artifactId>
    <name>MyCloud</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.7</java-version>
        <org.springframework-version>4.2.2.RELEASE</org.springframework-version> 
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
        <org.apache.logging.log4j-version>2.4.1</org.apache.logging.log4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>   

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${org.apache.logging.log4j-version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

2 个解决方案

#1


3  

M2Eclipse requires explicit instructions what to do with all Maven plugins bound to certain phases of a project build lifecycle. Such instructions are referenced as "lifecycle mapping" because they define how m2e maps information from the project pom.xml file to Eclipse configuration. One action that M2Eclipse can be instructed to do with a plugin execution is delegation to a project configurator.

M2Eclipse需要明确说明如何处理绑定到项目构建生命周期某些阶段的所有Maven插件。这些指令被称为“生命周期映射”,因为它们定义m2e如何将信息从项目pom.xml文件映射到Eclipse配置。可以指示M2Eclipse执行插件执行的一个操作是委托给项目配置器。

Quoting this reference page:

引用此参考页面:

A configurator mapping tells M2Eclipse to delegate workspace project configuration mapping for matching plugin execution to an implementation of AbstractProjectConfigurator registered with m2e using projectConfigurators extension point.

配置程序映射告诉M2Eclipse使用projectConfigurators扩展点将用于匹配插件执行的工作空间项目配置映射委托给使用m2e注册的AbstractProjectConfigurator的实现。

Those extension points are located inside each Eclipse plugins. If you take a look inside ${ECLIPSE_HOME}\plugins, you will notice a couple of jars whose name begin with org.eclipse.m2e. These are the M2Eclipse plugins.

这些扩展点位于每个Eclipse插件中。如果你看一下$ {ECLIPSE_HOME} \ plugins,你会发现一些名字以org.eclipse.m2e开头的罐子。这些是M2Eclipse插件。

Let's take the example of some of the configurators of the maven-war-plugin. To see where the configurators are declared, you can unzip org.eclipse.m2e.wtp_1.2.1.20150819-2220.jar (the name might be different according to your M2Eclipse version) and open the file lifecycle-mapping-metadata.xml. For the war packaging, this is what I have:

让我们以maven-war-plugin的一些配置器为例。要查看配置器的声明位置,可以解压缩org.eclipse.m2e.wtp_1.2.1.20150819-2220.jar(根据您的M2Eclipse版本名称可能不同)并打开文件lifecycle-mapping-metadata.xml。对于战争包装,这就是我所拥有的:

<lifecycleMapping>
  <packagingType>war</packagingType>
  <lifecycleMappingId>org.maven.ide.eclipse.wtp.WarLifecycleMapping</lifecycleMappingId>
  <pluginExecutions>
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.configurator</id>
        </configurator>
      </action>
    </pluginExecution>
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.warmanifest.configurator</id>
        </configurator>
      </action>
    </pluginExecution>           
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[0.0.1,2.0.1)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <error>
            <message>maven-war-plugin prior to 2.0.1 is not supported by m2e-wtp. Use maven-war-plugin version 2.0.1 or later</message>
        </error>
      </action>
    </pluginExecution>           
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.overlay.configurator</id>
        </configurator>
      </action>
    </pluginExecution>       
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[1.0,)</versionRange>
        <goals>
          <goal>inplace</goal>
          <goal>exploded</goal>
          <goal>manifest</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <ignore>
            <message>maven-war-plugin goals "inplace", "exploded", "manifest" are ignored by m2e</message>
        </ignore>
      </action>
    </pluginExecution>
  </pluginExecutions>
</lifecycleMapping>

You can see that this declares configurators. All of those configurators are the ones that you see in the dialog box picture in your post.

你可以看到这声明了配置器。所有这些配置程序都是您在帖子中的对话框图片中看到的配置程序。

Depending on your Eclipse installation, other configurators for maven-war-plugin can be declared:

根据您的Eclipse安装,可以声明maven-war-plugin的其他配置程序:

  • For JSF, they are declared in org.eclipse.m2e.wtp.jsf_1.2.1.20150819-2220.jar
  • 对于JSF,它们在org.eclipse.m2e.wtp.jsf_1.2.1.20150819-2220.jar中声明。
  • For JAX-RS, they are declared in org.eclipse.m2e.wtp.jaxrs_1.2.1.20150819-2220.jar
  • 对于JAX-RS,它们在org.eclipse.m2e.wtp.jaxrs_1.2.1.20150819-2220.jar中声明。

The M2Eclipse extension development page documents how to create new m2e extensions and takes the example of antlr3-maven-plugin.

M2Eclipse扩展开发页面记录了如何创建新的m2e扩展,并以antlr3-maven-plugin为例。

#2


-1  

you can use plugin for this Basically not a proper configuration This type of error generate..
org.eclipse.m2e lifecycle-mapping 1.0.0 some-group-id some-artifact-id [1.0.0,) some-goal

你可以使用插件这基本上不是一个正确的配置这种类型的错误生成.. org.eclipse.m2e生命周期映射1.0.0 some-group-id some-artifact-id [1.0.0,)some-goal

#1


3  

M2Eclipse requires explicit instructions what to do with all Maven plugins bound to certain phases of a project build lifecycle. Such instructions are referenced as "lifecycle mapping" because they define how m2e maps information from the project pom.xml file to Eclipse configuration. One action that M2Eclipse can be instructed to do with a plugin execution is delegation to a project configurator.

M2Eclipse需要明确说明如何处理绑定到项目构建生命周期某些阶段的所有Maven插件。这些指令被称为“生命周期映射”,因为它们定义m2e如何将信息从项目pom.xml文件映射到Eclipse配置。可以指示M2Eclipse执行插件执行的一个操作是委托给项目配置器。

Quoting this reference page:

引用此参考页面:

A configurator mapping tells M2Eclipse to delegate workspace project configuration mapping for matching plugin execution to an implementation of AbstractProjectConfigurator registered with m2e using projectConfigurators extension point.

配置程序映射告诉M2Eclipse使用projectConfigurators扩展点将用于匹配插件执行的工作空间项目配置映射委托给使用m2e注册的AbstractProjectConfigurator的实现。

Those extension points are located inside each Eclipse plugins. If you take a look inside ${ECLIPSE_HOME}\plugins, you will notice a couple of jars whose name begin with org.eclipse.m2e. These are the M2Eclipse plugins.

这些扩展点位于每个Eclipse插件中。如果你看一下$ {ECLIPSE_HOME} \ plugins,你会发现一些名字以org.eclipse.m2e开头的罐子。这些是M2Eclipse插件。

Let's take the example of some of the configurators of the maven-war-plugin. To see where the configurators are declared, you can unzip org.eclipse.m2e.wtp_1.2.1.20150819-2220.jar (the name might be different according to your M2Eclipse version) and open the file lifecycle-mapping-metadata.xml. For the war packaging, this is what I have:

让我们以maven-war-plugin的一些配置器为例。要查看配置器的声明位置,可以解压缩org.eclipse.m2e.wtp_1.2.1.20150819-2220.jar(根据您的M2Eclipse版本名称可能不同)并打开文件lifecycle-mapping-metadata.xml。对于战争包装,这就是我所拥有的:

<lifecycleMapping>
  <packagingType>war</packagingType>
  <lifecycleMappingId>org.maven.ide.eclipse.wtp.WarLifecycleMapping</lifecycleMappingId>
  <pluginExecutions>
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.configurator</id>
        </configurator>
      </action>
    </pluginExecution>
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.warmanifest.configurator</id>
        </configurator>
      </action>
    </pluginExecution>           
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[0.0.1,2.0.1)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <error>
            <message>maven-war-plugin prior to 2.0.1 is not supported by m2e-wtp. Use maven-war-plugin version 2.0.1 or later</message>
        </error>
      </action>
    </pluginExecution>           
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[2.0.1,)</versionRange>
        <goals>
          <goal>war</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <configurator>
          <id>org.maven.ide.eclipse.configuration.wtp.overlay.configurator</id>
        </configurator>
      </action>
    </pluginExecution>       
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <versionRange>[1.0,)</versionRange>
        <goals>
          <goal>inplace</goal>
          <goal>exploded</goal>
          <goal>manifest</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <ignore>
            <message>maven-war-plugin goals "inplace", "exploded", "manifest" are ignored by m2e</message>
        </ignore>
      </action>
    </pluginExecution>
  </pluginExecutions>
</lifecycleMapping>

You can see that this declares configurators. All of those configurators are the ones that you see in the dialog box picture in your post.

你可以看到这声明了配置器。所有这些配置程序都是您在帖子中的对话框图片中看到的配置程序。

Depending on your Eclipse installation, other configurators for maven-war-plugin can be declared:

根据您的Eclipse安装,可以声明maven-war-plugin的其他配置程序:

  • For JSF, they are declared in org.eclipse.m2e.wtp.jsf_1.2.1.20150819-2220.jar
  • 对于JSF,它们在org.eclipse.m2e.wtp.jsf_1.2.1.20150819-2220.jar中声明。
  • For JAX-RS, they are declared in org.eclipse.m2e.wtp.jaxrs_1.2.1.20150819-2220.jar
  • 对于JAX-RS,它们在org.eclipse.m2e.wtp.jaxrs_1.2.1.20150819-2220.jar中声明。

The M2Eclipse extension development page documents how to create new m2e extensions and takes the example of antlr3-maven-plugin.

M2Eclipse扩展开发页面记录了如何创建新的m2e扩展,并以antlr3-maven-plugin为例。

#2


-1  

you can use plugin for this Basically not a proper configuration This type of error generate..
org.eclipse.m2e lifecycle-mapping 1.0.0 some-group-id some-artifact-id [1.0.0,) some-goal

你可以使用插件这基本上不是一个正确的配置这种类型的错误生成.. org.eclipse.m2e生命周期映射1.0.0 some-group-id some-artifact-id [1.0.0,)some-goal