Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix m2e error in pom.xml: plugin execution not covered by lifecycle configuration?

I am having the title mentioned error in my Maven Java project. Below is a comparison of a good project and my troubled project. enter image description here

  • How to fix these 2 errors?
  • 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.

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.

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

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>
like image 258
smwikipedia Avatar asked Nov 17 '15 16:11

smwikipedia


People also ask

How do I fix the plugin error in POM xml?

Right click on the project > Maven > Update Project and check if it fixes the issue.

What is m2e plugin?

M2Eclipse provides tight integration for Apache Maven into the Eclipse IDE with the following features: Launching Maven builds from within Eclipse. Dependency management for Eclipse build path based on Maven's pom.


1 Answers

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.

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.

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.

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:

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

  • For JSF, they are declared in 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

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

like image 94
Tunaki Avatar answered Oct 15 '22 00:10

Tunaki