如何排除旧版本的maven依赖项并使用它的新版本?

我正在使用Maven项目,我有两个项目, ProjectAProjectB 。 我的ProjectA是一个maven库,其pom如下所示:

   4.0.0  com.texture.partial PartialPlatform 2.1.5-RELEASE  com.texture.transform.golden SampleClient 1.0.4   com.google.code.gson gson 2.2.4   com.texture.partial.core PartialKernel   com.texture.webres WebResPartial   javax.servlet javax.servlet-api provided   javax.servlet.jsp jsp-api provided   com.texture.kernel TextureServer   com.texture.kernel Kernel   com.texture.v3jars.Houston KernelDAL   com.texture.kernel uKernel   com.texture.kernel uKernelCore   org.springframework spring-context   org.springframework spring-beans   javax.servlet javax.servlet-api   org.springframework spring-test   org.springframework spring-asm   org.springframework spring-expression   org.springframework spring-aop   aopalliance aopalliance   org.apache.servicemix.bundles org.apache.servicemix.bundles.cglib   com.texture.partial.core ConfigWeb   com.texture.partial.core PartialWeb   com.googlecode.jmockit jmockit 1.7   junit junit test      maven-surefire-plugin  -javaagent:"${settings.localRepository}"/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar    org.codehaus.mojo cobertura-maven-plugin    **/test/**/*.class    xml html       

在上面的pom中, PartialKernel带来了各种Spring Framework依赖项的旧版本,如spring-corespring-web 。 它带来了3.2.8.RELEASE版本,我想使用这两个spring框架的最新版本,即4.1.6.RELEASE 。 排除来自PartialKernel并使用最新版本的旧版spring-corespring-web的正确方法是什么?

   org.springframework spring-web 4.1.6.RELEASE   org.springframework spring-core 4.1.6.RELEASE  

我需要使用最新版本,因为有些类只有最新版本。

在依赖项所需的库版本与您要使用的库之间可能存在不兼容的差异。 如果您愿意冒这个风险,可以使用maven exclusions来忽略传递依赖。

例如,你可以通过添加以下内容来排除spring-corePartialKernel

  com.texture.partial.core PartialKernel   org.springframework spring-core    

请注意,您必须为引入spring依赖项的每个依赖项执行此操作。

现在定义要在顶级pom 依赖关系管理部分中使用的spring-core的版本:

   org.springframework spring-core 4.1.6.RELEASE