Springboot 整合 Elasticsearch 报错 availableProcessors is already set to [4], rejecting [4]
- SpringBoot整合es的时候,启动报错。
nested exception is java.lang.IllegalStateException: availableProcessors is already set to [4], rejecting [4]
-
原因:
- 网上查找解决办法的时候,有可能是与netty冲突导致的
-
解决办法
-
可以添加这段配置。(没有用到)
@Configuration public class ElasticSearchConfig { @PostConstruct void init() { System.setProperty("es.set.netty.runtime.available.processors", "false"); } } -
在SpringBootApplication启动类中的main方法中添加一行代码:
public static void main(String[] args) { //要添加的代码 System.setProperty("es.set.netty.runtime.available.processors","false"); SpringApplication.run(WebApplication.class, args); }
-