I need artifact A. So, I included it in my pom.xml
<dependency>
<groupId>some.group</groupId>
<artifactId>some.artifact</artifactId>
<version>some.version</version>
</dependency
The artifact A uses artifact B which I absolutely don't want to be copied to my classpath. So, I used exclusions for B
<dependency>
<groupId>some.group</groupId>
<artifactId>some.artifact</artifactId>
<version>some.version</version>
<exclusions>
<exclusion>
<groupId>dontwant.group</groupId>
<artifactId>dontwant.artifact</artifactId>
</exclusion>
<exclusions>
</dependency
I don't have a dependency on B. But, I do have dependency on A and A depends on B. B is now not being copied to the classpath. Can this break my code ?
You use dependency A, A uses dependency B, but you excluded B from A. What is going to happen?
So avoid the exclusions, and put B onto the classpath unless you have very good reason not to (and you should add that reason to the question).