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会对此进行防范,因此首次实例化会因看到的非法状态异常而失败。

  • 相关阅读:
    Java的并发编程:创建线程的多种方式
    va_end (Variadic functions) – C 中文开发手册
    PHP headers_sent() 函数
    Java面试题:你用过的网站前端优化的技术有哪些?
    space-before-keywords (Rules) – Eslint 中文开发手册
    JavaScript 数据类型
    C 库函数 – free()
    屏幕 | screen (screen) – Electron 中文开发手册
    lrint (Numerics) – C 中文开发手册
    《《数据化风控》读书笔记分享》
  • 原文地址:https://www.cnblogs.com/panchanggui/p/15226119.html
Copyright © 2011-2022 走看看