title: How to exclude older versions of maven dependency and use new version of it?
body: <p>I am working with Maven project and I have two projects, <code>ProjectA</code> and <code>ProjectB</code>. My <code>ProjectA</code> is a maven library whose pom looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
      xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;com.texture.partial&lt;/groupId&gt;
          &lt;artifactId&gt;PartialPlatform&lt;/artifactId&gt;
          &lt;version&gt;2.1.5-RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;groupId&gt;com.texture.transform.golden&lt;/groupId&gt;
      &lt;artifactId&gt;SampleClient&lt;/artifactId&gt;
      &lt;version&gt;1.0.4&lt;/version&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;
              &lt;artifactId&gt;gson&lt;/artifactId&gt;
              &lt;version&gt;2.2.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.partial.core&lt;/groupId&gt;
              &lt;artifactId&gt;PartialKernel&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.webres&lt;/groupId&gt;
              &lt;artifactId&gt;WebResPartial&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
              &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.kernel&lt;/groupId&gt;
              &lt;artifactId&gt;TextureServer&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.kernel&lt;/groupId&gt;
              &lt;artifactId&gt;Kernel&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.v3jars.Houston&lt;/groupId&gt;
              &lt;artifactId&gt;KernelDAL&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.kernel&lt;/groupId&gt;
              &lt;artifactId&gt;uKernel&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.kernel&lt;/groupId&gt;
              &lt;artifactId&gt;uKernelCore&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-asm&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;aopalliance&lt;/groupId&gt;
              &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.servicemix.bundles&lt;/groupId&gt;
              &lt;artifactId&gt;org.apache.servicemix.bundles.cglib&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.partial.core&lt;/groupId&gt;
              &lt;artifactId&gt;ConfigWeb&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.texture.partial.core&lt;/groupId&gt;
              &lt;artifactId&gt;PartialWeb&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;com.googlecode.jmockit&lt;/groupId&gt;
              &lt;artifactId&gt;jmockit&lt;/artifactId&gt;
              &lt;version&gt;1.7&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;argLine&gt;-javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar&lt;/argLine&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;instrumentation&gt;
                          &lt;excludes&gt;
                              &lt;exclude&gt;**/test/**/*.class&lt;/exclude&gt;
                          &lt;/excludes&gt;
                      &lt;/instrumentation&gt;
                      &lt;formats&gt;
                          &lt;format&gt;xml&lt;/format&gt;
                          &lt;format&gt;html&lt;/format&gt;
                      &lt;/formats&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>In my above pom, <code>PartialKernel</code> is bringing older version of various Spring Framework dependencies like <code>spring-core</code>, <code>spring-web</code>. It is bringing <code>3.2.8.RELEASE</code> version and I want to use latest version of those two spring framework, which is <code>4.1.6.RELEASE</code>. What  is the right way to exclude older versions of <code>spring-core</code> and <code>spring-web</code> coming from <code>PartialKernel</code> and use latest version?</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;4.1.6.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;4.1.6.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>I need to use latest version since some classes are there in latest version only.</p>