Springboot整合Elasticsearch报错
今天使用SpringBoot整合Elasticsearch时候,相关的配置完成后,启动项目就报错了。
nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
我网上查询了一下,有人是是因为整合了Redis的原因。但是我把Redis相关的配置去掉后,问题还是没有解决,最后有人说是因为netty冲突的问题。
也有人给出了解决方式就是在项目初始化钱设置一下一个属性。在初始化之前加上System.setProperty("es.set.netty.runtime.available.processors", "false");
@Configuration
public class ElasticSearchConfig {
@PostConstruct
void init() {
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
}
我按照这种方法还是没有解决我这边项目的问题。
最后我直接把System.setProperty("es.set.netty.runtime.available.processors", "false");
发现这样可以解决我这边的问题。
相关文档:
1.Getting availableProcessors is already set to [1], rejecting [1] IllegalStateException exception
2.5.4 创建client PreBuiltTransportClient 抛 netty异常
3.Elasticsearch 5.4.1 - availableProcessors is already set
5.Issue with NettyRuntime$AvailableProcessorsHolder: number of available processors