私は親pomと統合pomを持っています:
積分pom
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
親pom
<modules>
<module>../example-business</module>
<module>../example-integration</module>
<module>../example-model</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
親にクリーンインストールを実行すると、次のエラーが発生します。
[INFO] Scanning for projects...
Downloading: http://www.example.com/content/groups/mirror/com/example/example-parent/0.0.1-SNAPSHOT/maven-metadata.xml
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.example:example-integration:0.0.1-SNAPSHOT (D:\dev\workspaces\example-git\example\example-integration\pom.xml) has 3 errors
[ERROR] 'dependencies.dependency.version' for org.json:json:jar is missing. @ line 22, column 15
[ERROR] 'dependencies.dependency.version' for commons-httpclient:commons-httpclient:jar is missing. @ line 27, column 15
[ERROR] 'dependencies.dependency.version' for com.example:example-model:jar is missing. @ line 32, column 15
しかし、統合pomのEffective POMを見ると、書かれたバージョンがあります。
それで、なぜ私はそれを構築できないのですか?
編集:
これがEFFECTIVE POMビューの一部です。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20131018</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>example-business</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
問題は、プロジェクトの構造と、子pomsでparent
をどのように定義したかということです。
子モジュールは、実際には、同じレベルではなく、親pomが存在する場所から1レベル上のフォルダーにあります(<module>../example-business</module>
から判断)。 mavenが子モジュールをビルドしようとすると、mavenリポジトリで利用できないため、親pomを見つけることができません(現在ビルド中のため、まだアップロードされていません)。
これを修正するには、子pomのparent
定義を変更して、実際のrelativePath
を親pomの場所に定義し、Mavenがそれを見つけられるようにする必要があります。したがって、次のように変更します。
<parent>
<groupId>com.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../name-of-folder-containing-parent-pom</relativePath>
</parent>
もちろん、name-of-folder-containing-parent-pom
をフォルダに変更する必要があります。
親の依存関係がローカルで解決されない理由を確認してください。 c:Users/name/.m2にあるsettings.xmlに何かが欠落している可能性があります。資格情報が正しいかどうかを確認し、公開されていない場合に備えてすべてのアーティファクトリンクを追加しました。