Mavenのサブモジュールから親モジュールの依存関係を削除する方法

親モジュールのパッケージを Maven サブモジュールから除外するには、 要素を使用して親モジュールの依存関係パッケージを除外できます。

親モジュールのpom.xmlファイル内で親モジュールへの依存関係を探し、その依存関係の要素に要素を追加してください。要素内で、除外したい親モジュールのgroupIdとartifactIdを指定してください。

たとえば、以下は、親モジュールの依存関係を1つ除外した、サブモジュールのpom.xmlファイルの例です。

<project>
...
<parent>
<groupId>com.example</groupId>
<artifactId>parent-module</artifactId>
<version>1.0.0</version>
</parent>
...
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>parent-module-dependency</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>excluded-dependency</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
...
</project>

上の例では、parent-module-dependencyは親モジュールの依存パッケージで、子モジュールのpom.xmlファイルに要素を追加し、除外したい依存パッケージのgroupIdとartifactIdを指定することで、子モジュールで親モジュールのその依存パッケージを外すことができます。

bannerAds