mavenどうやって親依存を除外する
サブモジュールの親依存を除外するには、親モジュールへのパスを要素で指定し、要素で不要な依存を指定します。
これは一例です。
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>1.0.0</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>child</artifactId>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>dependency</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>excluded-dependency</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
上のサンプルでは、ラベルは親モジュールの座標と相対パスを指定します。その後、ラベルはラベル内を使用して不要な依存関係を除外します。対応する依存関係を除外するために、ラベル内で正しい groupId と artifactId を使用していることを確認してください。
こうして、サブモジュールをビルドしたときに親モジュールの依存関係はサブモジュールに伝搬されません。