如何从(传递)依赖项中排除某些包?
How can I exclude some packages from (transitive) dependencies?
我依赖于 org.springframework.boot:spring-boot-starter-validation:jar:2.2.6.RELEASE:test
而依赖于 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
现在在我的测试类中,有两个候选静态导入assertNotNull
。
一个是
import static org.junit.jupiter.api.Assertions.assertNotNull;
另一个是
import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
有什么好的方法可以排除休眠的吗?
您只能排除整个依赖项,而不能排除部分依赖项。
你可以试试看:
<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>
我依赖于 org.springframework.boot:spring-boot-starter-validation:jar:2.2.6.RELEASE:test
而依赖于 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
现在在我的测试类中,有两个候选静态导入assertNotNull
。
一个是
import static org.junit.jupiter.api.Assertions.assertNotNull;
另一个是
import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
有什么好的方法可以排除休眠的吗?
您只能排除整个依赖项,而不能排除部分依赖项。
你可以试试看:
<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>