Search code examples
mavendependency-tree

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.

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

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?


Solution

  • You can only exclude whole dependencies, not parts of them.