【错误日志】Error creating bean with name ‘elasticsearchClient‘ defined in class path resource

错误日志:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-06 12:36:22.842 ERROR 11976 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

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 [4], rejecting [4]

这是因为你pom文件中依赖的Redis和ElasticSearch中都含有netty包且版本可能不一致:

		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId><!--netty-->
            <version>2.1.1.RELEASE</version>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId><!--netty-->
        </dependency>

解决办法

在启动类上加上如下代码:

// 解决elasticsearch启动保存问题
        System.setProperty("es.set.netty.runtime.available.processors", "false");

【错误日志】Error creating bean with name ‘elasticsearchClient‘ defined in class path resource_第1张图片

你可能感兴趣的:(错误日志,spring,boot,elasticsearch,redis)