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
If something depends on HttpClient
3.x
it will not work to substitute 4.x
since they are completely different APIs. You will get runtime errors when trying to access the code that relies on 3.x
.
Firstly please ensure that the mentioned artifact can work properly with the HttpClient 4.1.1.
We can define "the exclusion" for each dependency as it is mentioned at http://maven.apache.org/pom.html#Exclusions
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)
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.
Regards,
Charlee Ch.
Add a dependency on HttpClient 4.1.1 to your POM. Maven will recognize the conflict (assuming groupId and artifactId of httpclient have not changed) between your direct dependency, and the indirect dependency, and use the newer version. (not because its the newer one, but because it is the more direct one)
And it makes sense you can't edit other people's pom files - after all, you want carrot to use the newer http client only in your program, not in all programs that use carrot ...