报错异常:
背景:文章来源:https://www.toymoban.com/news/detail-676099.html
esUtils在common服务中、启动media服务时候、报这个异常、后排查esUtils在启动时候发生异常引起的、在相关bean中加入try{}catch{}即可解决问题文章来源地址https://www.toymoban.com/news/detail-676099.html
String[] split = url.split(","); HttpHost[] httpHosts = new HttpHost[split.length]; try{ if(split.length>0){ for (int i = 0; i < split.length; i++) { String s = split[i]; String[] split1 = s.split(":"); HttpHost http = new HttpHost(split1[0], Integer.parseInt(split1[1]), "http"); httpHosts[i] = http; } CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password)); RestClient httpClient = RestClient.builder(httpHosts) .setHttpClientConfigCallback( (HttpAsyncClientBuilder httpAsyncClientBuilder) -> httpAsyncClientBuilder.setDefaultCredentialsProvider( credentialsProvider)) .build(); client = new RestHighLevelClientBuilder(httpClient) .setApiCompatibilityMode(true) .build(); } }catch (Exception e){ e.printStackTrace(); }
到了这里,关于Error creating bean with name ‘esUtils‘ defined in file的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!