title: Maven: how to override the dependency added by a library
body: <p>Here's my generic problem:</p>
  <p>My project P depends on A which depends on B which depends on C which depends on version 1.0.1 of D.</p>
  <p>There's a problem with version 1.0.1 of D and I want to force the use of another module. I don't know how to declare this in my project's POMs since I haven't added a dependency on D directly. It's C which declared the dependency on D.</p>
  <p>Important: In this case, not only the version is changed, but the group &amp; artifact as well. So it's not just a matter of overriding the version of the dependency, but rather, of excluding a module and including another one.</p>
  <p>In the concrete case, D is StAX whose 1.0.1 has a <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6402423" rel="noreferrer">bug</a>. According to the notes in the bug, &quot;the problems were solved by replacing the stax-api-1.0.1 (maven GroupId = stax) by stax-api-1.0-2 (maven GroupId = javax.xml.stream)&quot; so I'm trying just that.</p>
  <p>Thus, D = stax:stax-api:jar:1.0.1 and C = org.apache.xmlbeans:xmlbeans:jar:2.3.0</p>
  <p>I'm using maven 2.0.9 in case it matters.</p>
  <p>Output of mvn dependency:tree&quot;</p>
  <pre><code>mvn dependency:tree
  [..snip..]
  [INFO] +- org.apache.poi:poi-ooxml:jar:3.6:compile
  [INFO] |  +- org.apache.poi:poi-ooxml-schemas:jar:3.6:compile
  [INFO] |  |  +- org.apache.xmlbeans:xmlbeans:jar:2.3.0:compile
  [INFO] |  |  |  \- stax:stax-api:jar:1.0.1:compile
  </code></pre>
  <p>In my project's POM I have the following dependency on &quot;A&quot;:</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
      &lt;artifactId&gt;poi&lt;/artifactId&gt;
      &lt;version&gt;3.6&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
      &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
      &lt;version&gt;3.6&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>