解決:Error creating bean with name 'elasticsearchClient', AvailableProcessors is already set to [4]

第一:

先看你的pom文件是否用了redis

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

如果在同時使用elastic search,請加上版本號

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>2.0.4.RELEASE</version>
        </dependency>

如果啓動還是報錯, 請嘗試在Application.class類中加上一句:

System.setProperty("es.set.netty.runtime.available.processors", "false");
public class SpringBootTestApplication extends SpringBootServletInitializer {

    public static void main(String[] args) throws Exception {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
        SpringApplication.run(SpringBootTestApplication.class, args);
    }
}

 

第二:根據你的es版本,是否需要客戶端pom , 請看API-JAVA-ES官方網站

類似的加入:

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>5.6.10</version>
        </dependency>

第三:你的elastic客戶端和服務端版本是否一致? 去maven倉庫看你依賴對應的版本,保持一致即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章