简体   繁体   English

Maven依赖性排除

[英]Maven dependency exclusion

I have the following dependency tree: 我有以下依赖树:

Project A
   ----Project B
           -----Project D
                 --------Project G
   ----Project C
           -----Project E
                 --------Project H
           -----Project F

The jar of Project G is no longer available and no attempt should be made to download it during build. Project G的jar不再可用,在构建期间不应尝试下载它。
The only accessible pom is that of Project A, which contains a dependency of Project B. 唯一可访问的pom是项目A的pom,它包含项目B的依赖项。
So we have added the following in the pom: 所以我们在pom中添加了以下内容:

<dependency>
      <groupId>xxxxx</groupId>
      <artifactId>Project B</artifactId>
      <version>xxxx</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <artifactId>Project G</artifactId>
          <groupId>xxxxxx</groupId>
        </exclusion>
      </exclusions>
</dependency>

Would adding an exclusion at the higher level of dependency work? 会在更高级别的依赖工作中添加排除吗?
How do we avoid Project G from being downloaded during build? 我们如何避免在构建期间下载Project G?

Yes. 是。 Exclusions work at any level. 排除在任何级别都有效。 Usually, I would use an exclude for project D instead of B because project D is the direct cause for the dependency. 通常,我会使用项目D的排除而不是B,因为项目D是依赖项的直接原因。

Note, however, that any other path could still bring in G as dependency because there are no global exclude statements. 但请注意,任何其他路径仍然可以将G作为依赖项引入,因为没有全局排除语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM