ElasticSearch集成SpringBoot(错误总结)

ElasticSearch集成SpringBoot启动报错

最近在使用es集成springboot时出现的几个问题,总结一哈哈;

连接不到es的节点

ERROR 12900 — [ main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{PanWdX8cSCucApEt1af63Q}{127.0.0.1}{127.0.0.1:9300}]

***配置文件出现问题***

配置es时出现横线,表示es的安装包和springboot中spring-boot-starter-data-elasticsearch的jar包版本号不一致;
ElasticSearch集成SpringBoot(错误总结)_第1张图片
***解决***

  • es安装包我使用的是5.2.2版本,spring-boot-starter-data-elasticsearch的jar包用的2.2.6,启动报错
    在这里插入图片描述

  • 更改springboot版本号为2.0.5
    ElasticSearch集成SpringBoot(错误总结)_第2张图片

启动时找不到bean

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘courseController’: Unsatisfied dependency expressed through field ‘courseServer’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘courseServerImpl’: Unsatisfied dependency expressed through field ‘courseElasticSearch’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘courseElasticSearch’: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.repository.support.NumberKeyedRepository]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Mapper for [intro] conflicts with existing mapping in other types:

原因是java代码中es的文档映射分词改变了,启动时报错找不到对应bean;

***解决:利用kibana清空es中的映射即可***

你可能感兴趣的:(elasticsearch,elasticsearch,spring,boot)