简体   繁体   English

如何从(传递)依赖项中排除一些包?

[英]How can I exclude some packages from (transitive) dependencies?

I depend on org.springframework.boot:spring-boot-starter-validation:jar:2.2.6.RELEASE:test which depends on org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:test . I depend on org.springframework.boot:spring-boot-starter-validation:jar:2.2.6.RELEASE:test which depends on org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:test .

[INFO] +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.6.RELEASE:test
[INFO] |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.33:test
[INFO] |  \- org.hibernate.validator:hibernate-validator:jar:6.0.18.Final:test

Now in my test clases, there are two candidates for statically importing assertNotNull .现在在我的测试用例中,有两个静态导入assertNotNull的候选者。

One is一个是

import static org.junit.jupiter.api.Assertions.assertNotNull;

And the other is另一个是

import static org.hibernate.validator.internal.util.Contracts.assertNotNull;

Is there any nice way to exclude the hibernate one?有什么好的方法可以排除 hibernate 之一吗?

You can only exclude whole dependencies, not parts of them.您只能排除整个依赖项,而不是其中的一部分。

You can try doing that:您可以尝试这样做:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
    <version>2.2.6.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
        </exclusion>
    </exclusions>
</dependency> 

暂无
暂无

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

相关问题 在Maven中,如何从特定依赖项中排除所有传递依赖项? - In Maven, how can I exclude all transitive dependencies from a particular dependency? 如何从Maven依赖项中排除某些包(在JAR中)? - How can I exclude some packages (within a JAR) from a Maven dependency? 如何从 maven 导入范围中排除 spring-boot-dependencies 的传递依赖 - How to exclude transitive dependencies of spring-boot-dependencies from maven import scope 尝试在具有嵌入式依赖项的Maven中构建OSGi捆绑包。 似乎无法从BND类路径中排除传递依赖项 - Trying to build an OSGi bundle in Maven with embedded dependencies. Can't seem to exclude transitive dependencies from BND classpath 如何使用Maven-assembly-plugin提供的作用域排除传递依赖关系? - How to exclude transitive dependencies with scope provided with maven-assembly-plugin? 如何从存储库中列出工件的传递依赖项? - How to list the transitive dependencies of an artifact from a repository? 如何排除来自Maven插件的Maven可传递依赖项? - How do I exclude a Maven transitive dependency that comes from a Maven plugin? 如何查看 Maven pom.xml 文件的传递依赖关系? - How can I view transitive dependencies of a Maven pom.xml file? 如何依赖具有传递依赖关系的库,这些依赖关系由 Maven 依赖管理调整,与调整的版本相同? - How can I depend on a library with transitive dependencies which are adjusted by Maven dependency management, at the same versions as adjusted? 如何在传递依赖中排除传递依赖? - How to exclude a transitive dependency inside a transitive dependency?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM