如何使用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);
}
而且我不确定该去上班了。