生命周期配置不包含插件执行?

时间:2014-12-10 17:39:55

标签: java eclipse maven

我的pom.xml文件中有以下配置

 <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>jslint</goal>
                        <goal>compress</goal>
                    </goals>
                </execution>
            </executions>
 .............
</plugin>

我在eclipse kepler中看到以下错误

Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: 
 net.alchim31.maven:yuicompressor-maven-plugin:1.3.0:compress (execution: default, phase: 
 compile)
- Plugin execution not covered by lifecycle configuration: 
 net.alchim31.maven:yuicompressor-maven-plugin:1.3.0:jslint (execution: default, phase: 
 compile)

我不确定是什么造成的?

1 个答案:

答案 0 :(得分:1)

你必须在maven的生命周期映射中添加这些jslint和compress。默认情况下,它不受maven生命周期的影响。在pom中,您可以使用快速链接添加生命周期映射,否则必须在pom.xml文件中手动添加它。

     <pluginManagement>
      <plugins>
         <plugin>
       <groupId>org.eclipse.m2e</groupId>
         <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                          <pluginExecutionFilter>
                            <groupId>net.alchim31.maven</groupId>
                            <artifactId>yuicompressor-maven-plugin</artifactId>
                                 <executions>
                                   <execution>
                                    <phase>compile</phase>
                                      <goals>
                                      <goal>jslint</goal>
                                       <goal>compress</goal>
                                     </goals>
                                    </execution>
                                  </executions>
                                  </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                            </lifecycleMappingMetadata>
                            < /configuration>
                         </plugin>
                       </plugins>
                </pluginManagement>

此代码将帮助maven将插件包含到生命周期映射中。希望它有所帮助!!