spring-boot-starter-data-elasticsearch 版本踩坑 天坑

spring-boot-starter-data-elasticsearch 版本踩坑,巨坑!(各种连接异常)

		<!--引入elasticsearch-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
		</dependency>

接入后,项目总是跑不起来

我的报错部分内容:

Exception in thread "I/O dispatcher 1" java.lang.AssertionError

CloseableHttpAsyncClientBase$1 66 run - I/O reactor terminated abnormally org.apache.http.nio.reactor.IOReactorException: I/O dispatch worker terminated abnormally

2021-09-01 19:04:34.758 ERROR org.springframework.boot.SpringApplication 826 reportFailure - Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productRepository': Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is org.springframework.data.elasticsearch.ElasticsearchException: Error while for indexExists request: org.elasticsearch.action.admin.indices.get.GetIndexRequest@2416378c

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.SimpleElasticsearchRepository]: Constructor threw exception; nested exception is org.springframework.data.elasticsearch.ElasticsearchException: Error while for indexExists request: org.elasticsearch.action.admin.indices.get.GetIndexRequest@2416378c
 

首先,maven会根据你的springboot版本自动为你匹配对应的版本spring-boot-starter-data-elasticsearch,比如我的springboot版本是2.2.13.RELEASE,spring-boot-starter-data-elasticsearch的匹配的版本是3.2.12.RELEASE。

 

经过一番折腾,发现Spring Data Elasticsearch 、Elasticsearch服务器、Spring Boot这三个版本号必须要一致才行,不然会有各种报错!!!

具体情况官网:Spring Data Elasticsearch - Reference Documentation

application.properties文件

#elasticsearch
spring.elasticsearch.rest.uris=192.168.11.6:9200

解决:

下载自己项目对应的elasticsearch版本重新安装即可,官网下载地址如下(地址的“6-8-12”是版本号可以改成自己项目对应的版本来下载):

Elasticsearch 6.8.12 | Elastic

另外,如果需要下载官方elasticsearch的可视化客户端工具kibana的话,也是需要版本和elasticsearch一致才行。我这里的elasticsearch是6-8-12,则kibana也需要是6-8-12版本的,不然会出行兼容问题。

https://www.elastic.co/cn/downloads/past-releases/kibana-6-8-12

  • 9
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值