Java 如何使用https将spring配置服务器与vertx一起使用?
我有一个vert.x应用程序,它使用SpringConfigServer获取值。当config server位于http上时,代码完全正常工作,但当spring config server移动到https时,代码不工作Java 如何使用https将spring配置服务器与vertx一起使用?,java,vert.x,Java,Vert.x,我有一个vert.x应用程序,它使用SpringConfigServer获取值。当config server位于http上时,代码完全正常工作,但当spring config server移动到https时,代码不工作 Vertx vertx = Vertx.vertx(); List<ConfigStoreOptions> configStores = new ArrayList<>(); List<String> configUrls = CoreConf
Vertx vertx = Vertx.vertx();
List<ConfigStoreOptions> configStores = new ArrayList<>();
List<String> configUrls = CoreConfigBean.getUrls(environment);
configUrls.forEach(url -> {
configStores.add(new ConfigStoreOptions().setType("spring-config-server")
.setConfig(new JsonObject().put("url", url).put("timeout",
Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT))));
});
ConfigRetrieverOptions configRetrieverOptions = new ConfigRetrieverOptions();
configStores.forEach(configRetrieverOptions::addStore);
ConfigRetriever retriever = ConfigRetriever.create(vertx, configRetrieverOptions.setScanPeriod(0));
CompletableFuture<JsonObject> configLoader = new CompletableFuture<JsonObject>();
retriever.getConfig(json -> {
if (json.succeeded()) {
JsonObject jsonObject = json.result();
if (jsonObject != null) {
jsonObject.iterator().forEachRemaining(sourceValue -> System.setProperty(sourceValue.getKey(),
sourceValue.getValue().toString()));
}
configLoader.complete(json.result());
json.mapEmpty();
retriever.close();
vertx.close();
} else {
json.otherwiseEmpty();
retriever.close();
vertx.close();
}
});
configLoader.get();
Vertx Vertx=Vertx.Vertx();
List configStores=new ArrayList();
List configUrls=CoreConfigBean.getUrls(环境);
configURL.forEach(url->{
添加(新的ConfigStoreOptions().setType(“spring配置服务器”)
.setConfig(新的JsonObject().put(“url”,url).put(“超时”,
Long.parseLong(ConfigurationUtil.CONFIG_SERVER_TIME_OUT));
});
ConfigRetrieverOptions ConfigRetrieverOptions=新的ConfigRetrieverOptions();
forEach(configRetrieverOptions::addStore);
ConfigRetriever retriever=ConfigRetriever.create(vertx,configRetrieverOptions.setScanPeriod(0));
CompletableFuture configLoader=新的CompletableFuture();
retriever.getConfig(json->{
if(json.succeed()){
JsonObject JsonObject=json.result();
if(jsonObject!=null){
jsonObject.iterator().ForEachLeving(sourceValue->System.setProperty(sourceValue.getKey()),
sourceValue.getValue().toString());
}
configLoader.complete(json.result());
json.mapepty();
retriever.close();
vertx.close();
}否则{
json.otherwisempty();
retriever.close();
vertx.close();
}
});
configLoader.get();
通过在配置中提供httpClientConfiguration
元素,尝试指定HttpClientOptions
:
。。。
.setConfig(新的JsonObject()
.put(“url”,url)
.put(“超时”,Long.parseLong(ConfigurationUtil.CONFIG\u SERVER\u TIME\u OUT))
.put(“httpClientConfiguration”,新的JsonObject()
.put(“trustAll”,true)
.put(“ssl”,true));
...