SpringBoot整合Elasticsearch 6.x版本的问题解决

项目场景:

Elasticsearch版本:6.3.2

解决方式适用6.X的大部分版本


问题描述

问题一

NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{HXq7jMLVQ7a90QI5wvuFHA}{127.0.0.1}{127.0.0.1:9300}]]

在这里插入图片描述

问题二

Caused by: java.lang.RuntimeException: 30,000 milliseconds timeout on connection http-outgoing-0 [ACTIVE]

在这里插入图片描述
问题三

org.junit.platform.commons.JUnitException: TestEngine with ID ‘junit-jupiter’ failed to discover tests

可能有的问题没有截出来或者没有遇到,下面统一解决


原因分析:

原因一:SpringBoot版本问题,SpringBoot的版本对应不上ES的版本

在这里插入图片描述

原因二:JDK版本问题

原因三:application配置文件问题

其他原因…


解决方案:

这里统一全部一起解决了

一、首先是pom依赖文件

SpringBoot版本选择2.1.X左右的,我这里选择 2.1.10.RELEASE版本

在这里插入图片描述

导入相关依赖时不指定版本,自动父坐标的版本一致(如图,统一都是2.1.10.RELEASE

在这里插入图片描述

二、application 配置文件

连接端口不是9200,换一个其他随便,名字换成 elasticsearch

在这里插入图片描述

三、测试类

加上@RunWith(SpringRunner.class),通过Test注解导入的是junit下的

在这里插入图片描述

四、其他的就没什么了,注意一下实体类、操作类没有写错的就行

在这里插入图片描述

记得elasticsearch要先启动起来,再启动程序

最后测试一下,查询所有,成功显示

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_47971206/article/details/125029482