0

m2eEclipse 用のプラグインをインストールし、それを使用して単純なアーキタイプを作成しました。小さなテスト ドライバーを作成し、(Maven を使用して) プロジェクトをビルドし、Java ソースをクラス ファイルにコンパイルしようとしています。

に行ってRun >> Run Configurations作成しNew Maven Buildます。名前を付けて、ベース ディレクトリをプロジェクト ルートに設定します。

選択しようとするGoalsと、何も表示されないため、追加/指定できません。ボタンをクリックしRunます。これが私のコンソール出力です:

[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.me:myproject:0.0.1-SNAPSHOT (C:\Users\me\workbench\eclipse\workspace\MyProject\pom.xml) has 3 errors
[ERROR]     'build.plugins.plugin.artifactId' is missing. @ line 145, column 17
[ERROR]     'build.plugins.plugin.groupId' is missing. @ line 144, column 14
[ERROR]     'build.plugins.plugin.version' for : must be a valid version but is ''. @ line 146, column 14
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException

<build>私の pom.xmlのタグは次のとおりです。

<build>
    <plugins>
        <plugin>
            <groupId></groupId>
            <artifactId></artifactId>
            <version></version>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compiler:compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

いくつかのこと:

  • これが (標準) Mavenフェーズである場合artifactId、私の はどうあるべきですか?groupIdversioncompile
  • これは Maven ビルドを起動する正しい方法Run Configurationsですか? Ant には、で定義されたすべてのターゲットを表示できるプラグインがありますbuild.xml。Maven/m2e にはそのような類似物はありません。
  • コンパイルのような単純なものにプラグインが必要なのはなぜですか? これは、あらゆるビルド ツールの標準的な部分であると考えられます。
4

1 に答える 1

1

Maven コンパイラのすべてのデフォルト設定を使用しているため、何も入力する必要はありません。本当に指定したい場合は、次の方法で行うことができます。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
</plugin>
于 2012-02-10T23:50:22.967 に答える