Java Maven依赖地狱(再次)
我在一个maven项目中工作,该项目声明了以下maven依赖项Java Maven依赖地狱(再次),java,maven,dependency-management,Java,Maven,Dependency Management,我在一个maven项目中工作,该项目声明了以下maven依赖项 <properties> <httpclient.version>4.2.5</httpclient.version> <cf-client-lib.version>1.1.1</cf-client-lib.version> .... </properties> <dependencies> <dependenc
<properties>
<httpclient.version>4.2.5</httpclient.version>
<cf-client-lib.version>1.1.1</cf-client-lib.version>
....
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-client-lib</artifactId>
<version>1.1.1</version>
</dependency>
...
<depedencies>
我已经阅读了上述可能的解决方案,但我认为我必须将我的项目更新到最新的库版本4.3.6,然后,我可以使用。但是,我能否找到一个更简单、暂时的解决方案来继续当前的开发?您是否有令人信服的理由不升级到新版本的httpclient?如果您这样做,那么您的选择是尝试让maven排除httpclient 4.3.6上的可传递依赖项。一般来说,这是一个坏主意,因为cloudfoundry的人可能有这样的依赖性是有原因的,但你可能会幸运地发现,这是一种替代品的减少。看一看httpclient是否真的被您的项目直接使用,或者它仅仅是pom的一部分,这取决于使用的及物性?谢谢您的回复。cf客户端需要httpclient v4.3.X,而我正在开发的项目需要4.2.5。我试图在我的项目中使用最新版本,但这不是一个直接的步骤,我需要执行一个迁移过程,我认为,这是一种方式。这不是Maven的问题,而是Maven揭示的项目中的一个问题。如果您的项目需要两个不同版本的httpclient,那么您打算如何工作呢?您不可能在一个版本或另一个版本中从库中选择性地加载类?除了像@David建议的那样幸运之外,这不会直接起作用,您需要迁移您的项目以使用更新版本的httpclient。我同意您的看法,@Tunaki。正如我在提问中提到的,我认为这是最好的选择:我正在完成这项任务。
[INFO] +- org.cloudfoundry:cloudfoundry-client-lib:jar:1.1.1:compileRELEASE:compile - omitted for conflict with 4.0.5.RELEASE)
[INFO] | +- (org.apache.httpcomponents:httpclient:jar:4.2.5:compile - version managed from 4.3.6; omitted for duplicate)
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
[INFO] | +- (org.apache.httpcomponents:httpcore:jar:4.2.5:compile)