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 で読み取ることができます。

しかし、あなたの問題に対するより実用的な解決策は、m2e build-helper コネクターを eclipse にインストールすることです。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 に答える
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 に答える
1

Maven は、M2E が Eclipse 内でプラグインを処理する方法 (ソース フォルダーの追加など) を決定するために使用する、m2e のライフサイクル マッピング アーティファクトをダウンロードしようとしています。何らかの理由で、このアーティファクトをダウンロードできません。インターネットに接続していますか?リポジトリから他のアーティファクトをダウンロードできますか? プロキシ設定?

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

このステップは私でうまくいきます:1.Eclipseでプロジェクトを削除します2.プロジェクトを再インポートします3.プロジェクトのターゲットフォルダーを削除します4.mvnまたはmvnwをインストールします

于 2019-09-15T07:55:43.280 に答える