如何正确忽略"生命周期配置未涵盖的插件执行:"错误

时间:2014-07-21 21:53:09

标签: java eclipse maven

今天早上升级到Eclipse Luna并安装m2e插件后,我的项目现在在我的项目的pom文件中显示错误。错误是:

- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.6:testResources (execution: default-testResources, phase: process-test-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.6:resources (execution: default-resources, phase: process-resources)

我原来的pom.xml看起来像这样:

<?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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.example</groupId>
   <artifactId>TestProject</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <dependencies>
      <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
         <version>6.8.8</version>
      </dependency>
      <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-java</artifactId>
         <version>2.42.0</version>
      </dependency>
   </dependencies>
   <build>
      <directory>target</directory>
      <outputDirectory>target/classes</outputDirectory>
      <finalName>${project.artifactId}-${project.version}</finalName>
      <sourceDirectory>src/main/java</sourceDirectory>
      <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
      <resources>
         <resource>
            <directory>src/main/resources</directory>
         </resource>
      </resources>
      <testOutputDirectory>target/test-classes</testOutputDirectory>
      <testSourceDirectory>src/test/java</testSourceDirectory>
      <testResources>
         <testResource>
            <directory>src/test/resources</directory>
         </testResource>
      </testResources>
   </build>
</project>

我尝试通过此处的文档更新它:http://wiki.eclipse.org/M2E_plugin_execution_not_covered

现在看起来像这样:

<?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/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.example</groupId>
   <artifactId>TestProject</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <dependencies>
      <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
         <version>6.8.8</version>
      </dependency>
      <dependency>
         <groupId>org.seleniumhq.selenium</groupId>
         <artifactId>selenium-java</artifactId>
         <version>2.42.0</version>
      </dependency>
   </dependencies>
   <build>
      <directory>target</directory>
      <outputDirectory>target/classes</outputDirectory>
      <finalName>${project.artifactId}-${project.version}</finalName>
      <sourceDirectory>src/main/java</sourceDirectory>
      <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
      <resources>
         <resource>
            <directory>src/main/resources</directory>
         </resource>
      </resources>
      <testOutputDirectory>target/test-classes</testOutputDirectory>
      <testSourceDirectory>src/test/java</testSourceDirectory>
      <testResources>
         <testResource>
            <directory>src/test/resources</directory>
         </testResource>
      </testResources>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
         </plugin>
         <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-resources-plugin</artifactId>
                           <versionRange>[1.0.0,)</versionRange>
                           <goals>
                              <goal>resources</goal>
                              <goal>testResources</goal>
                           </goals>
                        </pluginExecutionFilter>
                        <action>
                           <ignore />
                        </action>
                     </pluginExecution>
                  </pluginExecutions>
               </lifecycleMappingMetadata>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

但是,错误仍然显示出来。所以,这个配置肯定有问题,有人能指出我出错的地方吗?

1 个答案:

答案 0 :(得分:0)

根据接受答案添加<pluginManagement>代码可以解决我的问题:How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds

我以为我曾尝试过,但显然我没有正确地做到这一点。