微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

springboot整合elasticsearch

前言:

  • 环境

elasticsearch的版本是:7.4.2
springboot的版本:

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

依赖:

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

配置文件

spring:
  data:
    elasticsearch:
      cluster-name: elasticsearch
      cluster-nodes: 192.168.8.132:9300
      repositories:
        enabled: true
  • 启动、运行
  • 启动时:Failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{PD06vWIWQsi0zp2VpFBesQ}{192.168.8.132}{192.168.8.132:9300}]
    访问es时:org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{PD06vWIWQsi0zp2VpFBesQ}{192.168.8.132}{192.168.8.132:9300}]
    各种百度给出做好的解决办法是:当es版本大于7时,建议使用高级客户端:
    RestHighLevelClient
    下面开始整合高级客户端(明天写):

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐