覆盖maven中第三方jar的依赖关系

ars*_*nal 7 java eclipse maven

像这样的org.carrot2取决于commons-httpclient 3.1所以,我怎么能这样改commons-httpclient 3.1HttpClient 4.1.1.我在日食工作.因为我想commons-httpclient:3.1从那些依赖于这个jar文件并且我想替换的人中删除 HttpClient 4.1.1.

所以我试图做什么..我org.carrot2从依赖层次结构文件夹双击这个并进入它的pom.xml文件并尝试更改commons-httpclient 3.1为httpclient 4.1.1但它不允许我更改为退格键并且删除不是正在努力..

任何建议将不胜感激..

Cha*_*suk 14

首先请确保所提到的工件可以与HttpClient 4.1.1一起正常工作.

我们可以为每个依赖项定义" 排除 ",如http://maven.apache.org/pom.html#Exclusions中所述.

排除明确告诉Maven您不希望包含作为此依赖项依赖项的指定项目(换句话说,它的传递依赖项)

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

<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>
Run Code Online (Sandbox Code Playgroud)

我希望这可能有助于实现这一要求.

问候,

Charlee Ch.