You can find the dependency tree using mvn dependency:tree
command.
From the tree, you can exclude the artifact.
Example output:
[INFO] | +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.20.0:test
[INFO] | | +- org.seleniumhq.selenium:selenium-api:jar:2.20.0:test
[INFO] | | +- net.sourceforge.htmlunit:htmlunit:jar:2.9:test
[INFO] | | | +- xalan:xalan:jar:2.7.1:test
[INFO] | | | | \- xalan:serializer:jar:2.7.1:test
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.1:test
[INFO] | | | +- commons-lang:commons-lang:jar:2.6:test
[INFO] | | | +- org.apache.httpcomponents:httpmime:jar:4.1.2:test
[INFO] | | | +- commons-codec:commons-codec:jar:1.4:test
[INFO] | | | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.9:test
[INFO] | | | +- xerces:xercesImpl:jar:2.9.1:test
[INFO] | | | | \- xml-apis:xml-apis:jar:1.3.04:test
In case the dependency is transitive, you can do as follow based on the above tree:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.20</version>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.9</version>
<!-- i dont want u -->
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>