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");
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步