使用HTTPClientBuilder.create()。build()与HTTPClient.custom()。build()有什么区别

时间:2017-08-17 20:10:02

标签: apache-httpclient-4.x

我正在尝试使用Java中的Apache HTTPClient为REST Web服务创建用于构建框架的HTTPClient。

在这里,我发现我们可以使用以下两种方式创建客户端。我想知道它们之间的区别。

1.HTTPCLientBuilder.create()。建立()

2.HTTPClients.custom()。build()

1 个答案:

答案 0 :(得分:0)

答案是关于SO,只是有点隐藏。从这个question

重新发出幸福感99的答案
HttpClient (interface)

implemented by:

CloseableHttpClient - ThreadSafe.

DefaultHttpClient - ThreadSafe BUT deprecated, use HttpClientBuilder instead.
HttpClientBuilder - NOT ThreadSafe, BUT creates ThreadSafe CloseableHttpClient.

Use to create CUSTOM CloseableHttpClient.
HttpClients - NOT ThreadSafe, BUT creates ThreadSafe CloseableHttpClient.

Use to create DEFAULT or MINIMAL CloseableHttpClient.

所以当你写.custom()然后不要set任何自定义的东西时,显然没有差异