httpcliet、commons-httpclient、defaulthttpclient的区别和联系

来源:互联网 发布:cue软件 编辑:程序博客网 时间:2024/05/16 06:38

org.apache.httpcomponents » httpclient

原来,commons-httpclient 是 apache-commons 项目下的一个子项目,后来被 HttpComponents 取代,

除此以外,在apache的官网上下载httpclient的jar包时,会发现它是在一个叫HttpComponent的项目下,这个HttpComponent是apache的顶级项目。而以前的commons的那三个包都是commons的项目下。在HttpComponent的网页上,看到了这样的文字: HttpComponents Client is a successor of and replacement forCommons HttpClient 3.x. Users of Commons HttpClient are strongly encouraged to upgrade.

也就是说commons下的commons-httpclient不在更新和维护了,用commons-httpclient的用户也建议更新到httpclient这个包。

后者提供了更好的性能和更大的灵活性。
原文地址如下:http://hc.apache.org/httpclient-3.x/


PS:
commons-httpclient的GAV地址为
<dependency>
  <groupId>commons-httpclient</groupId>
  <artifactId>commons-httpclient</artifactId>
  <version>3.1</version>
</dependency>
其最新版本为3.1,且已经不再更新;

HttpComponents的GAV地址为
<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.5.1</version>
</dependency>

截止目前(2016-01-05),最新版本为4.5.1;

DefaultHttpClient实现了HttpClient接口,使用时提示

The type DefaultHttpClient is deprecated

HttpClient client = new DefaultHttpClient();
改为:

HttpClient client = HttpClientBuilder.create().build();






0 0
原创粉丝点击