0

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?

Jin Kwon
  • 20,295
  • 14
  • 115
  • 184

2 Answers2

2

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

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
0

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> 
nisanarz
  • 895
  • 1
  • 12
  • 22