【问题标题】:m2e lifecycle-mapping not found未找到 m2e 生命周期映射
【发布时间】:2011-11-16 14:41:45
【问题描述】:

我正在尝试使用解决方案described here 来解决烦人的“生命周期配置未涵盖的插件执行:org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (执行:默认,阶段:生成源)”当我将以下插件放在我的 pom.xml 上时:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
    <execution>
        <phase>generate-sources</phase>
        <goals><goal>add-source</goal></goals>
        <configuration>
            <sources>
                <source>src/bootstrap/java</source>
            </sources>
        </configuration>
    </execution>
</executions>
</plugin>

但是当我运行 mvn clean install 我得到这个:

原因:在存储库中找不到 POM 'org.eclipse.m2e:lifecycle-mapping':无法从任何存储库下载工件

有人知道如何让 m2e 和 maven 开心吗?

【问题讨论】:

标签: maven-2 maven maven-plugin m2eclipse m2e


【解决方案1】:

这一步对我有用: 1.在eclipse上删除你的项目 2.重新导入项目 3.删除项目中的目标文件夹 4. mvn 或 mvnw 安装

【讨论】:

  • 能否请您以适当的格式安排步骤并详细说明您的答案,这将有助于其他人快速浏览您的答案并更好地理解它。谢谢你:)
【解决方案2】:

令人惊讶的是,这 3 个步骤帮助了我:

mvn clean
mvn package
mvn spring-boot:run

【讨论】:

    【解决方案3】:

    m2e 1.7 引入了一个new syntax for lifecycle mapping metadata,它不再导致此警告:

    <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <executions>
        <execution>
    
            <!-- This executes the goal in Eclipse on project import.
                 Other options like are available, eg ignore.  -->
            <?m2e execute?>
    
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration>
                <sources>
                    <source>src/bootstrap/java</source>
                </sources>
            </configuration>
        </execution>
    </executions>
    </plugin>
    

    【讨论】:

      【解决方案4】:

      由于缺少插件配置而发生(根据vaadin's demo pom.xml 评论):

      此插件的配置用于存储 Eclipse m2e 设置 只要。它对 Maven 构建本身没有影响。

      <pluginManagement>
          <plugins>
              <!--This plugin's configuration is used to store Eclipse m2e ettings only. It has no influence on the Maven build itself.-->
              <plugin>
                  <groupId>org.eclipse.m2e</groupId>
                  <artifactId>lifecycle-mapping</artifactId>
                  <version>1.0.0</version>
                  <configuration>
                      <lifecycleMappingMetadata>
                          <pluginExecutions>
                              <pluginExecution>
                                  <pluginExecutionFilter>
                                      <groupId>com.vaadin</groupId>
                                      <artifactId>
                                          vaadin-maven-plugin
                                      </artifactId>
                                      <versionRange>
                                          [7.1.5,)
                                      </versionRange>
                                      <goals>
                                          <goal>resources</goal>
                                          <goal>update-widgetset</goal>
                                          <goal>compile</goal>
                                          <goal>update-theme</goal>
                                          <goal>compile-theme</goal>
                                      </goals>
                                  </pluginExecutionFilter>
                                  <action>
                                      <ignore></ignore>
                                  </action>
                              </pluginExecution>
                          </pluginExecutions>
                      </lifecycleMappingMetadata>
                  </configuration>
              </plugin>
          </plugins>
      </pluginManagement>
      

      【讨论】:

      • 一些如何添加&lt;version&gt; 而不是&lt;versionRange&gt; 不会传播到子模块。我必须使用&lt;versionRange&gt; 来让子模块正常运行。
      【解决方案5】:

      org.eclipse.m2e:lifecycle-mapping 插件实际上并不存在。它应该从您的pom.xml&lt;build&gt;&lt;pluginManagement&gt; 部分使用。这样,它不是由 Maven 解析的,而是可以被 m2e 读取的。

      但更实用的解决方案是在 eclipse 中安装 m2e build-helper 连接器。您可以从Window > Preferences > Maven > Discovery > Open Catalog 安装它。这样build-helper-maven-plugin:add-sources 将在 Eclipse 中被调用,而无需您更改您的 pom.xml

      【讨论】:

      • 有同样的问题,但不太清楚这个答案是什么意思,有没有机会举个例子?
      • 有谁知道在哪里可以找到“org.scala-tools:maven-scala-plugin”的“eclipse 连接器”?
      • 我认为他的意思实际上是 build/pluginManagement 部分,而不是 dependencyManagement。
      • 没错,Hendy,感谢您注意到错误。我用正确的信息编辑了我的答案。
      • Fred,安装 build-helper 连接器并没有解决原来的“生命周期未涵盖的插件执行”错误。但是添加 PluginManagement 配置可以。
      【解决方案6】:

      我是这样做的:我将 m2e 的生命周期映射插件放在单独的配置文件中,而不是默认的 部分。该配置文件在 Eclipse 构建期间通过存在 m2e 属性自动激活(而不是在 settings.xml 或其他方式中手动激活)。这将处理 m2e 案例,而命令行 maven 将简单地跳过配置文件和 m2e 生命周期映射插件而没有任何警告,每个人都很高兴。

      <project>
        ...
        <profiles>
          ...
          <profile>
            <id>m2e</id>
            <!-- This profile is only active when the property "m2e.version"
              is set, which is the case when building in Eclipse with m2e. -->
            <activation>
              <property>
                <name>m2e.version</name>
              </property>
            </activation>
            <build>
              <pluginManagement>
                <plugins>
                  <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                      <lifecycleMappingMetadata>
                        <pluginExecutions>
                          <pluginExecution>
                            <pluginExecutionFilter>
                              <groupId>...</groupId>
                              <artifactId>...</artifactId>
                              <versionRange>[0,)</versionRange>
                              <goals>
                                <goal>...</goal>
                              </goals>
                            </pluginExecutionFilter>
                            <action>
      
                              <!-- either <ignore> XOR <execute>,
                                you must remove the other one. -->
      
                              <!-- execute: tells m2e to run the execution just like command-line maven.
                                from m2e's point of view, this is not recommended, because it is not
                                deterministic and may make your eclipse unresponsive or behave strangely. -->
                              <execute>
                                <!-- runOnIncremental: tells m2e to run the plugin-execution
                                  on each auto-build (true) or only on full-build (false). -->
                                <runOnIncremental>false</runOnIncremental>
                              </execute>
      
                              <!-- ignore: tells m2eclipse to skip the execution. -->
                              <ignore />
      
                            </action>
                          </pluginExecution>
                        </pluginExecutions>
                      </lifecycleMappingMetadata>
                    </configuration>
                  </plugin>
                </plugins>
              </pluginManagement>
            </build>
          </profile>
          ...
        </profiles>
        ...
      </project>
      

      【讨论】:

      • 绝对不可能同时为所有插件配置生命周期映射插件?
      • @BlackEye 您可以为不同的插件添加多个pluginExecution 条目。
      • 您可以通过自动修复“忽略”Maven 错误来生成此样板 XML。然后将 改为 true
      • 感谢有关 m2e.version 属性的信息,根本找不到任何文档,但它似乎有效!
      • 最佳答案。也不知道这个属性。
      【解决方案7】:

      我遇到了同样的问题,其中:

      在 Eclipse 中未找到处理 build-helper-maven-plugin:1.8:add-source 的市场条目。有关详细信息,请参阅帮助。

      然后单击 Window > Preferences > Maven > Discovery > open catalog 按钮将报告没有连接。

      在 Centos 6.4 和 OSX 上从 7u40 更新到 7u45 解决了这个问题。

      【讨论】:

        【解决方案8】:

        尝试使用build/pluginManagement 部分,例如:

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.bsc.maven</groupId>
                                        <artifactId>maven-processor-plugin</artifactId>
                                        <versionRange>[2.0.2,)</versionRange>
                                        <goals>
                                            <goal>process</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>                         
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        

        这是一个在 Eclipse 内增量编译期间生成捆绑清单的示例:

        <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.felix</groupId>
                                            <artifactId>maven-bundle-plugin</artifactId>
                                            <versionRange>[1.0.0,)</versionRange>
                                            <goals>
                                                <goal>manifest</goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <execute />
                                        </action>
                                    </pluginExecution>
                                </pluginExecutions>
                            </lifecycleMappingMetadata>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
        
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>2.3.7</version>
                    <extensions>true</extensions>
                    <configuration>
                        <instructions>
                        </instructions>
                    </configuration>
                    <executions>
                        <execution>
                            <id>manifest</id>
                            <phase>process-classes</phase>
                            <goals>
                                <goal>manifest</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        

        versionRange 是必需的,如果省略 m2e(从 1.1.0 开始)将抛出 NullPointerException。

        【讨论】:

        • 迄今为止最好的解决方案。只需在 下为 org.eclipse.m2e 添加 即可解决上述问题
        【解决方案9】:

        你可以使用这个虚拟插件:

        mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping -Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo
        

        生成项目后安装/部署它。

        【讨论】:

          【解决方案10】:

          我在 m2e 上为此打开了一个(微不足道的)错误。如果您希望警告消息永远消失,请为它投票...

          https://bugs.eclipse.org/bugs/show_bug.cgi?id=367870

          【讨论】:

            【解决方案11】:

            Maven 正在尝试下载 m2e 的生命周期映射工件,M2E 使用它来确定如何在 Eclipse 中处理插件(添加源文件夹等)。由于某种原因,无法下载此工件。你有互联网连接吗?可以从存储库下载其他工件吗?代理设置?

            有关 Maven 的更多详细信息,请尝试打开 M2E 调试输出(设置/Maven/调试输出复选框),它可能会为您提供有关无法从存储库下载的更多详细信息。

            【讨论】:

            • 那个神器不见了。我可以下载其他工件。它永远消失了吗?
            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2012-06-04
            • 1970-01-01
            • 2015-07-15
            • 2011-10-02
            • 2012-10-31
            • 1970-01-01
            相关资源
            最近更新 更多