availableProcessors is already set to [8], rejecting [8]


錯誤詳細信息:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchClient' 
defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
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]

關鍵信息如下:

Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8]

通過關鍵字搜索,找到了解決辦法,原因是因為SpringBoot的netty和elasticsearch的netty相關jar沖突

只需在啟動類加入如下代碼即可解決(注意,這段代碼要放在SpringApplication.run(Application.class, args)之前才行,否則不會生效):

System.setProperty("es.set.netty.runtime.available.processors", "false");

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM