Java-Maven(十一):Maven 项目出现pom.xml错误:Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin

Maven项目出现ERROR:

eclipse更新了Maven插件后,让后就出现了以下错误:

Description Resource Path Location Type
Conflicting lifecycle mapping (plugin execution "org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (execution: default-compile, phase: compile)"). To enable full functionality, remove the conflicting mapping and run Maven->Update Project Configuration.    
pom.xml 
/icos-mrfingerlib-common
line 1    
Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (execution: default-compile, phase: compile)    
pom.xml  
/icos-mrfingerlib-common    
line 35    
Maven Project Build Lifecycle Mapping Problem
         

解决方案1:

1)Window --> Perferences -->  Maven  --> Lifecycle Mapping

发现目录:E:\work\git\ICOS-DASpark-Project\.metadata\.plugins\org.eclipse.m2e.core下并没有“lifecycle-mapping-metadata.xml”文件。

新建文件lifecycle-mapping-metadata.xml,并填写内容为:

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
  <pluginExecutions>
    <pluginExecution>
      <pluginExecutionFilter>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <versionRange>2.5.1</versionRange>
        <goals>
          <goal>testCompile</goal>
          <goal>compile</goal>
        </goals>
      </pluginExecutionFilter>
      <action>
        <ignore />
      </action>
    </pluginExecution>
  </pluginExecutions>
</lifecycleMappingMetadata>

2)记得点击 ”Reload workspace lifecycle mappings metadata“按钮

3)update Project 就可以了

解决方案2:

直接在pom.xml文件中加入如

    <build>
        <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-compiler-plugin</artifactId>
                                        <versionRange>[2.5,)</versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

记得保存之后在项目上右击Maven -> Update Project...

 

posted @ 2019-07-18 16:49  cctext  阅读(1730)  评论(0编辑  收藏  举报