美文网首页
nested exception is java.lang.Il

nested exception is java.lang.Il

作者: 爱的旋转体 | 来源:发表于2018-12-03 09:17 被阅读0次

springboot2.0.6.RELEASE中整合了redis和Elasticsearch报错:

Factory method 'testClient' threw exception; nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]

原因分析:
SpringBoot 2.X 的 spring-boot-starter-data-redis 默认是以 lettuce 作为连接池的, 而在 lettuce , elasticsearch transport 中都会依赖netty, 二者的netty 版本不一致,不能够兼容。
解决办法:
在SpringBoot 启动类中设置
es.set.netty.runtime.available.processors 为 false。

@SpringBootApplication
public class Application {

    public static void main(String[] args) {

        // 设置环境变量,解决Es的netty与Netty服务本身不兼容问题
        System.setProperty("es.set.netty.runtime.available.processors","false");
        SpringApplication.run(Application.class, args);
    }
}

参考https://blog.csdn.net/fxbin123/article/details/81809606?utm_source=blogxgwz3

相关文章

网友评论

      本文标题:nested exception is java.lang.Il

      本文链接:https://www.haomeiwen.com/subject/twpecqtx.html