2017-08-08 72 views
0

当我把这个代码中发现:org.apache.http.conn.ssl.SSLConnectionSocketFactory不在HttpClientBuilder.build()

HttpClientBuilder clientBuilder = HttpClientBuilder.create(); 
LaxRedirectStrategy laxStrategy = new LaxRedirectStrategy(); 
clientBuilder = clientBuilder.setRedirectStrategy(laxStrategy); 

httpClient = clientBuilder.build(); // FAILS HERE 

我得到java.lang.NoSuchFieldError的:INSTANCE

看起来像它找不到类org.apache.http.conn.ssl.SSLConnectionSocketFactory,但是该类在我的类路径中的jar中找到。我怎样才能找到罪魁祸首?

谢谢! Mike

回答

0

这看起来像一个依赖性问题给我。可能是您正在寻找的课程存在于您的CP上的两个不同的罐子中。

0

在类路径中有不同版本的Apache Commons HTTP Client。你可以用jdk 8以下的版本试试。

<dependency> 
    <groupId>org.apache.httpcomponents</groupId> 
    <artifactId>httpclient</artifactId> 
    <version>4.1.1</version> 
</dependency>