我正在使用 Spring asyncresttempate 同时调用多个服务。这些服务通过 SSL 公开。您能告诉我如何使用 SSL 证书和 AsyncResttemplate 异步调用服务吗?我们可以将 RestTemplate 与 HttpConnectionFactory 一起使用,如何对 AsyncRestTemplate 执行相同的操作。
我使用的是 Spring 4.3,JDK 8。
最佳答案
您可以使用AsyncClientHttpRequestFactory:
CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
.setSSLHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)
.setSSLContext(getSSLCOntext(keyStore)).build();
AsyncClientHttpRequestFactory reqFactory =
new HttpComponentsAsyncClientHttpRequestFactory(httpclient);
AsyncRestTemplate restTemplate = new AsyncRestTemplate(reqFactory);
关于java - Spring AsyncResttemplate HTTPs (SSL) 服务调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45361960/