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
网友评论