对于普通的 URLConnection 则需要
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyPort", "8888");
对于 Apache-HttpClient
HttpClient client = HttpClientBuilder.create().setProxy( new HttpHost("127.0.0.1", 8888)).build();