1. 程式人生 > >springcloud 中的zuul整合Elasticsearch報錯availableProcessors is already set to [4], rejecting [4]

springcloud 中的zuul整合Elasticsearch報錯availableProcessors is already set to [4], rejecting [4]

今天使用springboot整合springcloud zuul和elasticsearch時,報錯。

僅僅使用springboot和elasticsearch沒有問題,springboot和eureka和elasticsearch整合也沒有問題,springboot和eureka和elasticsearch和zuul整合出現了問題,

原因是SpringBoot的netty和elasticsearch的netty相關jar衝突
解決辦法:
在啟動類新增:
System.setProperty("es.set.netty.runtime.available.processors", "false");

package cn.ac.iie;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@EnableZuulProxy
public class App {
    public static void main(String[] args) {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
        ConfigurableApplicationContext run = SpringApplication.run(App.class, args);
    }
}