【含错误解决】创建 Maven Web 项目

创建一个web Maven项目,方法如下:

【new】-【maven project】-【之后按图中所示选择,命名】-【Finish】

二:映射空间相关错误

第一个 : Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)
第二个 :Conflicting lifecycle mapping
第三个:在其中,还出现了上一个问题的情况(缺少东西),解决方法都是 update 勾选

第一个 :Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)
第二个 :Conflicting lifecycle mapping

第三个解决办法文章链接 :https://mp.csdn.net/postedit/82115827

映射空间地址:【G:/sts-workspace/.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml】

产生错误之前我做了:

    1.根据之前搜索到的东西,自己创建了【lifecycle-mapping-metadata.xml】文件,按照百度的内容填写上,并且修改了【映射文件位置】

【正确的解决方法】:

     1.映射空间应该是在自己设置的工作空间下,【G:\sts-workspace】 ,【.metadata】类型的文件夹在这里,

【lifecycle-mapping-metadata.xml】文件应该在【G:\sts-workspace\.metadata\.plugins\org.eclipse.m2e.core】下

        2.找到eclipse或者sts软件【安装位置】文件下的插件【E:\ spring-tool-suite-3.7.3.RELEASE-e4.5.2-win32-x86_64 \ sts-3.7.3.RELEASE \ plugins】

        3.搜索【org.eclipse.m2e.lifecyclemapping.defaults_xxxxxx.jar】这类的jar文件,解压可以看到其中有【lifecycle-mapping-metadata.xml】,解压到【G:\ sts-workspace \ .metadata \ .plugins \ org.eclipse.m2e.core】映射空间下(解压后的xml文件里面是有内容的)

        4.根据上图,在Eclipse(sts)中,修改【更改映射文件位置】到那个【lifecycle-mapping-metadata.xml】路径,然后保存

        5.根据错误,修改其中的内容,错误完整提示内容是

【Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.7.0 :compile (execution: default-compile, phase: compile)】

(网上找来的,我的版本是3.7.0,网上是3.1,把版本改成错误提示的那个就好了)

        6.修改的【添加】代码如下:(代码插入的位置很明显,我们可以看到好几个这样格式的内容,在其中插入一个这个就好了)

 <pluginExecution>

            <pluginExecutionFilter>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-compiler-plugin</artifactId>

            <versionRange>[3.7,)</versionRange>

            <goals>

                  <goal>testCompile</goal>

            <goal>compile</goal>

            </goals>

      </pluginExecutionFilter>

      <action>

            <ignore></ignore>

      </action>

</pluginExecution>

        7.重新更新项目,不用勾选更新下载。

注意:

    1.自己创建的文件早早删除就可以了或者解压之后替换掉

    2.出现了【冲突的生命周期映射】这样的错误之后,提示我删除多余的生命周期,这个多余的就是我一开始自己瞎创建的,而不是解压的那个。

附件,【lifecycle-mapping-metadata.xml】完整内容如下:(除了我自己添加的,其余都是解压后就有的)

<?xml version="1.0" encoding="UTF-8"?>

<lifecycleMappingMetadata>

  <lifecycleMappings>

    <lifecycleMapping>

      <packagingType>war</packagingType>

      <lifecycleMappingId>org.eclipse.m2e.jdt.JarLifecycleMapping</lifecycleMappingId>

    </lifecycleMapping>

  </lifecycleMappings>

  <pluginExecutions>

    <!--  standard maven plugins -->

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-resources-plugin</artifactId>

        <goals>

          <goal>resources</goal>

          <goal>testResources</goal>

          <goal>copy-resources</goal>

        </goals>

        <versionRange>[2.4,)</versionRange>

      </pluginExecutionFilter>

      <action>

        <execute>

          <runOnIncremental>true</runOnIncremental>

        </execute>

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-resources-plugin</artifactId>

        <goals>

          <goal>resources</goal>

          <goal>testResources</goal>

          <goal>copy-resources</goal>

        </goals>

        <versionRange>[0.0.1,2.4)</versionRange>

      </pluginExecutionFilter>

      <action>

        <error>

          <message>maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.</message>

        </error>

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-enforcer-plugin</artifactId>

        <goals>

          <goal>enforce</goal>

        </goals>

        <versionRange>[1.0-alpha-1,)</versionRange>

      </pluginExecutionFilter>

      <action>

        <ignore>

          <message>maven-enforcer-plugin (goal "enforce") is ignored by m2e.</message>

        </ignore>

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-invoker-plugin</artifactId>

        <goals>

          <goal>install</goal>

        </goals>

        <versionRange>[1.6-SONATYPE-r940877,)</versionRange>

      </pluginExecutionFilter>

      <action>

        <ignore>

          <message>maven-invoker-plugin (goal "install") is ignored by m2e.</message>

        </ignore>

      </action>

    </pluginExecution>

    <pluginExecution>

            <pluginExecutionFilter>

            <groupId>org.apache.maven.plugins</groupId>

            <artifactId>maven-compiler-plugin</artifactId>

            <versionRange>[3.7,)</versionRange>

            <goals>

                  <goal>testCompile</goal>

            <goal>compile</goal>

            </goals>

      </pluginExecutionFilter>

      <action>

            <ignore></ignore>

      </action>

      </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-remote-resources-plugin</artifactId>

        <versionRange>[1.0,)</versionRange>

        <goals>

          <goal>process</goal>

        </goals>

      </pluginExecutionFilter>

      <action>

        <ignore>

          <message>maven-remote-resources-plugin (goal "process") is ignored by m2e.</message>

        </ignore>

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-eclipse-plugin</artifactId>

        <versionRange>[0,)</versionRange>

        <goals>

          <goal>configure-workspace</goal>

          <goal>eclipse</goal>

          <goal>clean</goal>

          <goal>to-maven</goal>

          <goal>install-plugins</goal>

          <goal>make-artifacts</goal>

          <goal>myeclipse</goal>

          <goal>myeclipse-clean</goal>

          <goal>rad</goal>

          <goal>rad-clean</goal>

        </goals>

      </pluginExecutionFilter>

      <action>

        <error>

          <message>maven-eclipse-plugin is not compatible with m2e</message>

        </error>

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.apache.maven.plugins</groupId>

        <artifactId>maven-source-plugin</artifactId>

        <versionRange>[2.0,)</versionRange>

        <goals>

          <goal>jar-no-fork</goal>

          <goal>test-jar-no-fork</goal>

          <!-- theoretically, the following goals should not be bound to lifecycle, but ignore them just in case  -->

          <goal>jar</goal>

          <goal>aggregate</goal>

          <goal>test-jar</goal>

        </goals>

      </pluginExecutionFilter>

      <action>

        <ignore/>

      </action>

    </pluginExecution>

    <!-- commonly used codehaus plugins -->

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.codehaus.mojo</groupId>

        <artifactId>animal-sniffer-maven-plugin</artifactId>

        <versionRange>[1.0,)</versionRange>

        <goals>

          <goal>check</goal>

        </goals>

      </pluginExecutionFilter>

      <action>

        <ignore />

      </action>

    </pluginExecution>

    <pluginExecution>

      <pluginExecutionFilter>

        <groupId>org.codehaus.mojo</groupId>

        <artifactId>buildnumber-maven-plugin</artifactId>

        <versionRange>[1.0-beta-1,)</versionRange>

        <goals>

          <goal>create</goal>

        </goals>

      </pluginExecutionFilter>

      <action>

        <ignore />

      </action>

    </pluginExecution>

  </pluginExecutions>

</lifecycleMappingMetadata>

猜你喜欢

转载自blog.csdn.net/RachelHYC/article/details/82116067
今日推荐