覆盖maven中第三方jar的依赖关系 [英] Override dependencies of third party jar in maven

查看:787
本文介绍了覆盖maven中第三方jar的依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像这样 org.carrot2 取决于 commons-httpclient 3.1 所以我可以如何更改这个 commons-httpclient 3.1 HttpClient 4.1.1 。我在日食工作因为我要删除
commons-httpclient:3.1 从那些依赖这个jar文件,我想替换为 HttpClient 4.1

Like this org.carrot2 is depending on commons-httpclient 3.1 So how I can change this commons-httpclient 3.1 to HttpClient 4.1.1. I am working in eclipse. As I want to remove commons-httpclient:3.1 from those who are depending on this jar file and I want to replace with HttpClient 4.1.1.

所以我试图做的..我加倍点击这个 org.carrot2 从依赖层次文件夹,并进入其pom.xml文件,并试图将 commons-httpclient 3.1 更改为httpclient 4.1.1,但它不允许我更改为空格,删除不能正常工作。

So what I was trying to do.. I doubled click on this org.carrot2 from dependency hierarchy folder and went into its pom.xml file and was trying to change commons-httpclient 3.1 to httpclient 4.1.1 but it is not allowing me to change as backspace and delete is not working on that..

任何建议将不胜感激。

推荐答案

首先,请确保所提到的工件可以正常使用HttpClient 4.1.1

Firstly please ensure that the mentioned artifact can work properly with the HttpClient 4.1.1.

我们可以为 http: //maven.apache.org/pom.html#Exclusions


排除明确告诉Maven
你不想包括
指定的项目,这是依赖关系的
(换句话说,
它的传递依赖)

Exclusions explicitly tell Maven that you don't want to include the specified project that is a dependency of this dependency (in other words, its transitive dependency)

排除:排除项包含一个或
个排除元素,每个
包含一个groupId和artifactId
表示要排除的依赖关系。
与可选项不同,可能或不可能
被安装和使用,排除
主动从
依赖关系树中删除自己。

exclusions: Exclusions contain one or more exclusion elements, each containing a groupId and artifactId denoting a dependency to exclude. Unlike optional, which may or may not be installed and used, exclusions actively remove themselves from the dependency tree.



<dependencies>
  <dependency>
    <groupId>the_group</groupId>
    <artifactId>the_artifact</artifactId>
    <version>the_version</version>
    <exclusions>
      <exclusion>
        <groupId>the_apache_group</groupId>
        <artifactId>the_http_client_artifact</artifactId>
      </exclusion>
    </exclusions>
  </dependency>

  <dependency>
    <groupId>the_apache_group</groupId>
    <artifactId>the_http_client_artifact</artifactId>
    <version>4.1.1</version>
  </dependency>
  ...
</dependencies>

我希望这可能有助于达到要求。

I hope this may help to achieve the requirement.

问候,

Charlee Ch。

Charlee Ch.

这篇关于覆盖maven中第三方jar的依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆