zoukankan      html  css  js  c++  java
  • elasticsearch5.6.1.集成springboot 遇到的坑

    [ERROR]Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method ‘elasticsearchClient’ threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8]

    翻译:[错误]未能实例化[org.elasticsearch.client.transport.TransportClient]:工厂方法“elasticsearchClient”引发异常;嵌套异常为java.lang.IllegalStateException:availableProcessors已设置为[8],拒绝[8]

    在spring同时整合redis(短信服务),ES(elasticsearch,查询服务)时,会抛出以上异常

    解决方案

    方案1.启动类上加上一段代码

    System.setProperty("es.set.netty.runtime.available.processors","false");

    -----------------------

    spring boot 集成redis和elasticsearch遇到的坑
    起因是因为我在一个已经集成了redis的spring boot项目上引入了spring-data-elasticsearch包,配好环境之后开始报如下的错误。

    Failed to instantiate [org.elasticsearch.client.transport.TransportClient]: Factory method 'elasticsearchClient' threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
    解决办法:

    @SpringBootApplication
    
    public class SpringBootExampleApplication {
    
     
    
    public static void main(String[] args) {
    
    System.setProperty("es.set.netty.runtime.available.processors","false");
    
    SpringApplication.run(SpringbootexampleApplication.class, args);
    
    }
    
    }
    

      

    原因:程序的其他地方使用了Netty,这里指redis。这影响在实例化传输客户端之前初始化处理器的数量。 实例化传输客户端时,我们尝试初始化处理器的数量。 由于在其他地方使用Netty,因此已经初始化并且Netty会对此进行防范,因此首次实例化会因看到的非法状态异常而失败。

  • 相关阅读:
    面向对象程序设计寒假作业2
    面向对象程序设计寒假作业1
    自我介绍
    3组-Alpha冲刺-1/6
    3组 需求分析报告
    3组 团队展示
    第一次个人编程作业
    第一次博客作业
    我罗斯方块最终篇
    我罗斯方块设计
  • 原文地址:https://www.cnblogs.com/panchanggui/p/15226119.html
Copyright © 2011-2022 走看看