Error creating bean with name ‘esUtils‘ defined in file

报错异常:

背景:

esUtils在common服务中、启动media服务时候、报这个异常、后排查esUtils在启动时候发生异常引起的、在相关bean中加入try{}catch{}即可解决问题

复制代码
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();
}
复制代码
相关推荐
suweijie7683 小时前
SpringCloudAlibaba | Sentinel从基础到进阶
java·大数据·sentinel
公贵买其鹿4 小时前
List深拷贝后,数据还是被串改
java
xlsw_7 小时前
java全栈day20--Web后端实战(Mybatis基础2)
java·开发语言·mybatis
神仙别闹8 小时前
基于java的改良版超级玛丽小游戏
java
黄油饼卷咖喱鸡就味增汤拌孜然羊肉炒饭8 小时前
SpringBoot如何实现缓存预热?
java·spring boot·spring·缓存·程序员
暮湫8 小时前
泛型(2)
java
超爱吃士力架8 小时前
邀请逻辑
java·linux·后端
南宫生8 小时前
力扣-图论-17【算法学习day.67】
java·学习·算法·leetcode·图论
转码的小石9 小时前
12/21java基础
java
李小白669 小时前
Spring MVC(上)
java·spring·mvc