[英]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.