当我运行以下代码时:
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
public static void main(String[] args) {
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet("https://www.google.com/?q=java");
try {
HttpResponse response = client.execute(request);
System.out.println(response.getStatusLine());
} catch (Exception e) {
e.printStackTrace();
}
}
我收到以下错误:
线程“主”中的异常java.lang.NoSuchFieldError:实例为 org.apache.http.conn.ssl.SSLConnectionSocketFactory。(SSLConnectionSocketFactory.java:144) 在 org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966) 在HttpExample.main(HttpExample.java:12)