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();
}
复制代码
相关推荐
pshdhx_albert4 小时前
AI agent实现打字机效果
java·http·ai编程
沉鱼.445 小时前
第十二届题目
java·前端·算法
赫瑞6 小时前
数据结构中的排列组合 —— Java实现
java·开发语言·数据结构
周末也要写八哥7 小时前
多进程和多线程的特点和区别
java·开发语言·jvm
惜茶8 小时前
vue+SpringBoot(前后端交互)
java·vue.js·spring boot
杰克尼8 小时前
springCloud_day07(MQ高级)
java·spring·spring cloud
NHuan^_^10 小时前
SpringBoot3 整合 SpringAI 实现ai助手(记忆)
java·人工智能·spring boot
Mr_Xuhhh10 小时前
从ArrayList到LinkedList:理解链表,掌握Java集合的另一种选择
java·数据结构·链表
错把套路当深情10 小时前
Java 全方向开发技术栈指南
java·开发语言
han_hanker10 小时前
springboot 一个请求的顺序解释
java·spring boot·后端