title: How to use same lib for compile and run at Eclipse?
body: <p>I have a maven project that was imported as java project. When I run it, I get </p>
  
  <pre><code>Handling error: NestedServletException, Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.apache.commons.lang.time.DateUtils.addDays(Ljava/util/Date;I)Ljava/util/Date;
  </code></pre>
  
  <p>Using <a href="https://stackoverflow.com/a/42097/3026886">this answer</a> I got this line:</p>
  
  <pre><code>[Loaded org.apache.commons.lang.time.DateUtils from file:/C:/Users/user/.m2/repository/commons-lang/commons-lang/2.0/commons-lang-2.0.jar]
  </code></pre>
  
  <p>But at <code>pom.xml</code> it's:</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;commons-lang&lt;/groupId&gt;
              &lt;artifactId&gt;commons-lang&lt;/artifactId&gt;
              &lt;version&gt;2.6&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>Considering I have this libs at <code>Java Build Path</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/rf89j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rf89j.png" alt="enter image description here"></a></p>
  
  <p>and </p>
  
  <p><a href="https://i.stack.imgur.com/yuEF7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yuEF7.png" alt="enter image description here"></a></p>
  
  <p>How could I resolve this problem? Where can I assured compare my run vs compile libs?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>this is the output of <code>mvn dependency:tree -Dverbose -Dincludes=commons-lang</code>:</p>
  
  <pre><code>    [INFO] com.companyName.gestao.projectName:projectName-webapp:war:1.0.0-SNAPSHOT
      [INFO] \- com.companyName.gestao.projectName:projectName-business:jar:1.0.0-SNAPSHOT:compile
      [INFO]    +- com.companyName.commons.utils:companyName-commons-utils:jar:1.14.5:compile
      [INFO]    |  \- softdes:softdes-all:jar:1.6.23:compile
      [INFO]    |     \- commons-lang:commons-lang:jar:2.6:compile (version managed from 2.0)
      [INFO]    \- net.sf.jasperreports:jasperreports:jar:companyName-6.4.0.4:compile
      [INFO]       \- org.codehaus.castor:castor-xml:jar:1.3.3:compile
      [INFO]          +- org.codehaus.castor:castor-core:jar:1.3.3:compile
      [INFO]          |  \- (commons-lang:commons-lang:jar:2.6:compile - version managed from 2.0; omitted for duplicate)
      [INFO]          \- (commons-lang:commons-lang:jar:2.6:compile - version managed from 2.0; omitted for duplicate)
  </code></pre>
  
  <p>Running the same command at <code>business</code> subproject(at same directory level that <code>webapp</code> project):</p>
  
  <pre><code>[INFO] com.companyName.gestao.projectName:projectName-business:jar:1.0.0-SNAPSHOT
  [INFO] +- com.companyName.commons.utils:companyName-commons-utils:jar:1.14.5:compile
  [INFO] |  \- softdes:softdes-all:jar:1.6.23:compile
  [INFO] |     \- commons-lang:commons-lang:jar:2.0:compile
  </code></pre>
  
  <p>So <code>webapp</code> depends upon <code>business</code> that depends upon <code>companyName-commons-utils</code> that depends upon <code>softdes-all</code> that depends upon <code>commons-lang</code> version 2. But <code>webapp</code> must use <code>commons-lang</code> version 2.6.</p>
  
  <p>Can I accomplish this by changing dependency order at <code>pom.xml</code>?</p>
  
  <p><strong>SECOND EDIT</strong></p>
  
  <p>After adding <code>&lt;exclusion&gt;</code> to <code>commons-lang</code> at <code>business</code> dependency, I run dependency tree maven as stated above. Now, besides <code>BUILD SUCCESS</code>, maven doesn't have any tree printed, as below:</p>
  
  <pre><code>        PS C:\workspace\projectName-dev\webapp&gt; mvn dependency:tree -Dverbose -Dincludes=commons-lang
      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Conciliador - webapp 1.0.0-SNAPSHOT
      [INFO] ------------------------------------------------------------------------
      [INFO]
      [INFO] --- maven-dependency-plugin:2.10:tree (default-cli) @ conciliador-webapp ---
      [WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 8.629s
      [INFO] Finished at: Thu May 17 13:21:08 BRT 2018
      [INFO] Final Memory: 29M/494M
      [INFO] ------------------------------------------------------------------------
      PS C:\workspace\projectName-dev\webapp&gt;
  </code></pre>
  
  <p>I discovered that <code>commons-lang</code> dependency is inside <code>dependencyManagement</code> as stated <a href="https://stackoverflow.com/a/37280943/3026886">here</a> and <code>DateUtils</code> is still loaded from 2.0 version Jar. What could be done?</p>