在 Maven 中,如何从特定依赖项中排除所有传递依赖项? [英] In Maven, how can I exclude all transitive dependencies from a particular dependency?

查看:50
本文介绍了在 Maven 中,如何从特定依赖项中排除所有传递依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一个依赖项中排除所有传递依赖项.在某些地方我看到它建议为此使用通配符

I want to exclude all transitive dependencies from one dependency. In some places I've seen it suggested to use a wildcard for that

<dependency>
  <groupId>myParentPackage</groupId>
  <artifactId>myParentProject</artifactId>
  <version>1.00.000</version>            
  <exclusions>
    <exclusion>
        <groupId>*</groupId>
        <artifactId>*</artifactId>
    </exclusion>
  </exclusions>
</dependency>

当我这样做时,我会收到警告:

When I do that I get a warning:

'dependencies.dependency.exclusions.exclusion.groupId' for myParentPackage:myParentProject:jar with value '*' does not match a valid id pattern. @ line 146, column 30

声明本身是成功的:传递依赖在我的构建中确实被忽略了.

The declaration itself is successful though: The transitive dependencies really are ignored in my build.

我还发现了一个旧的功能请求,它确实请求正是这个功能

I've also found a old feature request that does request exactly this feature

所以现在我不知道这是否是我不应该使用的已弃用功能、警告是否错误,或者该功能尚未完全实现(我使用的是 Maven 3.0.4)...有人知道更多吗?

So now I don't know if this is a deprecated feature that I shouldn't use, if the warning's wrong, or of the feature hasn't been completely implemented yet (I'm using Maven 3.0.4) ...Does anybody know more about this?

推荐答案

这是 Maven 3.2.1 中支持的功能 - 参见发行说明中的​​传递依赖排除"部分.

This is a supported feature in Maven 3.2.1 - see 'Transitive dependency excludes' section in the release notes.

这篇关于在 Maven 中,如何从特定依赖项中排除所有传递依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆