相关文章推荐
慈祥的仙人掌  ·  XMLHttpRequest - ...·  1 年前    · 
怕考试的熊猫  ·  laravel ...·  2 年前    · 
行走的扁豆  ·  Pytorch转tensorflow、tfl ...·  2 年前    · 
不拘小节的排球  ·  springboot-vue-websock ...·  2 年前    · 

maven父pom jar 排除依赖包

在 Maven 中,我们可以使用 <exclusions> 元素来排除依赖包,该元素可以用于父 POM 或子模块的 POM 中。

例如,假设我们的父 POM 依赖于 A、B、C 三个依赖包,但子模块只需要 A 和 B 两个依赖包,我们就可以在子模块的 POM 中使用 <exclusions> 元素来排除 C 依赖包。

以下是示例代码:

<!-- 父 POM -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>A</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>com.example</groupId>
  <artifactId>B</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>com.example</groupId>
  <artifactId>C</artifactId>
  <version>1.0.0</version>
</dependency>
<!-- 子模块 POM -->
<dependency>
  <groupId>com.example</groupId>
  <artifactId>A</artifactId>
  <version>1.0.0</version>
  <exclusions>
    <exclusion>
      <groupId>com.example</groupId>
      <artifactId>C</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>com.example</groupId>
  <artifactId>B</artifactId>
  <version>1.0.0</version>
  <exclusions>
    <exclusion>
      <groupId>com.example</groupId>
      <artifactId>C</artifactId>
    </exclusion>
  </exclusions>
</dependency>

在上面的示例中,子模块的 POM 文件中,我们使用 <exclusions> 元素来排除了 C 依赖包,这样子模块就只会依赖于 A 和 B 两个依赖包了。

希望这个回答能够帮到你,如果你有其他问题,可以继续提问。

  •