使用resttemplate消耗https网址

时间:2019-03-19 15:46:00

标签: resttemplate

如何使用spring boot来使用具有resttemplate代理的https url,我使用包含

的unit方法
private void init() {

final int proxyPortNum = Integer.parseInt(this.proxyPort);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(this.proxyHost, 
proxyPortNum),new UsernamePasswordCredentials("?", "?"));
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
clientBuilder.useSystemProperties();
clientBuilder.setProxy(new HttpHost(this.proxyHost, proxyPortNum));
clientBuilder.setDefaultCredentialsProvider(credsProvider);
clientBuilder.setProxyAuthenticationStrategy(new ProxyAuthenticationStrategy());

CloseableHttpClient client = clientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(client);

this.restTemplate.setRequestFactory(factory);

}

而且我不确定该去上班了。

0 个答案:

没有答案