60

我正在尝试使用此处描述的解决方案来解决烦人的“生命周期配置未涵盖的插件执行: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 开心?

4

11 回答 11

112

org.eclipse.m2e:lifecycle-mapping插件实际上并不存在。它应该从<build><pluginManagement>您的pom.xml. 这样,它不会被 Maven 解析,但可以被 m2e 读取。

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

于 2011-09-14T22:47:58.647 回答
11

尝试使用该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。

于 2012-07-15T02:49:02.050 回答
9

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

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

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

于 2012-02-14T11:22:15.180 回答
9

我是这样做的:我将 m2e 的生命周期映射插件放在单独的配置文件中,而不是默认的 <build> 部分。该配置文件在 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>
于 2014-02-05T10:14:36.080 回答
6

m2e 1.7为生命周期映射元数据引入了一种新语法,不再导致此警告:

<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>
于 2017-01-09T08:14:39.553 回答
4

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

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

于 2012-01-04T16:39:11.240 回答
3

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

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

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

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

于 2013-10-16T19:25:27.840 回答
1

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

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

于 2011-09-14T03:56:32.437 回答
1

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

mvn clean
mvn package
mvn spring-boot:run
于 2019-09-10T18:26:16.357 回答
0

它是由于缺少插件配置而发生的(根据vaadin 的演示 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>
于 2015-04-27T19:55:42.770 回答
0

这一步对我有用: 1. 在 Eclipse 上删除您的项目 2. 重新导入项目 3. 删除项目上的目标文件夹 4. mvn 或 mvnw install

于 2019-09-15T07:55:43.280 回答