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();
}
复制代码
相关推荐
韩师学子--小倪8 小时前
fastjson与gson的toString差异
java·json
Drawing stars8 小时前
JAVA后端 前端 大模型应用 学习路线
java·前端·学习
nbsaas-boot8 小时前
SQL Server 存储过程开发规范(公司内部模板)
java·服务器·数据库
行百里er8 小时前
用 ThreadLocal + Deque 打造一个“线程专属的调用栈” —— Spring Insight 的上下文管理术
java·后端·架构
玄〤8 小时前
黑马点评中 VoucherOrderServiceImpl 实现类中的一人一单实现解析(单机部署)
java·数据库·redis·笔记·后端·mybatis·springboot
J_liaty9 小时前
Spring Boot拦截器与过滤器深度解析
java·spring boot·后端·interceptor·filter
亲爱的非洲野猪9 小时前
Java锁机制八股文
java·开发语言
rgeshfgreh9 小时前
C++字符串处理:STL string终极指南
java·jvm·算法
Zoey的笔记本10 小时前
「支持ISO27001的GTD协作平台」数据生命周期管理方案与加密通信协议
java·前端·数据库
lpfasd12310 小时前
Spring Boot 4.0.1 时变更清单
java·spring boot·后端