1:前言

为什么是SpringBoot2.2.5,不是其他的SpringBoot版本,原因有两个:

1:SpringBoot2.2.0以上才能支持ElasticSearch7.x版本。

2:SpringBoot2.2.6/SpringBoot2.2.7整合ElasticSearch7.9时启动测试类会报错。

github issues链接地址

实际报错信息截图:



下面开始讲如何在SpringBoot中使用ElasticSearch7.9.

2:依赖

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

全部依赖:

3:结构

3.1:项目总体结构:

3.2:application.properties

server.port=8771

spring.main.banner-mode=off

spring.elasticsearch.rest.uris=http://192.168.1.218:9200

spring.elasticsearch.rest.username=elastic

spring.elasticsearch.rest.password=elastic

spring.elasticsearch.jest.read-timeout=9s

spring.elasticsearch.jest.connection-timeout=9s

3.3:ES model类:

@Data
@Accessors(chain = true)
@Document(indexName = "elastic_aopi_entity", type = "_doc", useServerConfiguration = true)
public class ElasticAopiEntity { @Id
private Long id; /* @Version
private Long version;*/ private String aopiName; private String coder; }

3.4:ES 持久层类

import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

public interface ElasticAopiEntityDao extends ElasticsearchRepository<ElasticAopiEntity,Long> {
}

4:测试

测试用例部分截图:



运行后Kibana查看:

本文GitHub地址

SpringBoot2.2.5整合ElasticSearch7.9.2的更多相关文章

  1. SpringBoot2.1.6 整合CXF 实现Webservice

    SpringBoot2.1.6 整合CXF 实现Webservice 前言 最近LZ产品需要对接公司内部通讯工具,采用的是Webservice接口.产品框架用的SpringBoot2.1.6,于是采用 ...

  2. springboot2.1.7整合mybati3.5.2与mysql8.0.13

    springboot2.x已经发布一段时间,博主在这里使用springboot2.1.7整合mybatis3.5.2,使用的数据库为mysql8.0.13 1. 导入依赖 <!--mysql-- ...

  3. springboot2.x版本整合redis(单机/集群)(使用lettuce)

    在springboot1.x系列中,其中使用的是jedis,但是到了springboot2.x其中使用的是Lettuce. 此处springboot2.x,所以使用的是Lettuce.关于jedis跟 ...

  4. SpringBoot2.0之整合Kafka

    maven依赖: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www. ...

  5. SpringBoot2.0之整合Apollo

    Spring Boot客户端对接阿波罗服务器端 核心源码都在这个压缩包里面 封装好了环境 运行shell脚本就ok了 下面进入到本地maven仓库: 远程仓库apollo的jar包 只能打包到本地或者 ...

  6. SpringBoot2.0之整合ElasticSearch

    就类比数据库到时候去实现 服务器端配置 集群名字  与yml名字一致 pom: <project xmlns="http://maven.apache.org/POM/4.0.0&qu ...

  7. SpringBoot2.0之整合ActiveMQ(发布订阅模式)

    发布订阅模式与前面的点对点模式很类似,简直一毛一样 注意:发布订阅模式 先启动消费者 公用pom: <project xmlns="http://maven.apache.org/PO ...

  8. SpringBoot2.0之整合ActiveMQ(点对点模式)

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. SpringBoot2.0之整合Dubbo

    Dubbo支持协议 Dubbo支持dubbo.rmi.hessian.http.webservice.thrift.redis等多种协议,但是Dubbo官网是推荐我们使用Dubbo协议的. Sprin ...

随机推荐

  1. Malaysia Trip Memory ('-ωก)

    独白 ​ 初次见面,睡意阑珊.日轮.稀疏.惨白色.墨绿色,\(\rho_{atm}>\rho_{space}\) 的作用被赤道所隐藏,一时的不知所从,斑斓成了单一.之后的故事,踏上一辆盛装打扮的 ...

  2. jackson学习之八:常用方法注解

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  3. 从微信小程序到鸿蒙js开发【04】——list组件

    目录: 1.可滚动区域 2.list + list-item 3.list + list-item-group + list-item 1.可滚动区域 在许多场景中,页面会有一块区域是可滚动的,比如这 ...

  4. Java中详述线程间协作

    线程协作 首先引入一段代码: package 线程间数据共享; import java.util.Date; public class Watch { private static String ti ...

  5. Qt update刷新之源码分析(一)

    在做GUI开发时,要让控件刷新,会调用update函数:那么在调用了update函数后,Qt究竟基于什么原理.执行了什么代码使得屏幕上有变化?本文就带大家来探究探究其内部源码. Qt手册中关于QWid ...

  6. Codeforces Round #650 (Div. 3) A. Short Substrings

    题目链接:https://codeforces.com/contest/1367/problem/A 题意 给出一个字符串 $t$,找出原字符串 $s$,$t$ 由 $s$ 从左至右的所有长为 $2$ ...

  7. AtCoder Beginner Contest 168

    比赛链接:https://atcoder.jp/contests/abc168/tasks A - ∴ (Therefore) 题意 给出一个由数字组成的字符串 $s$,要求如下: 如果 $s$ 以 ...

  8. JavaScript——内置对象

  9. VuePress 最新教程

    VuePress 最新教程 https://vuepress.vuejs.org/ https://github.com/vuejs/vuepress VuePress plugins 插件通常会为 ...

  10. Swift All in One

    Swift All in One Swift 5.3 https://github.com/apple/swift-evolution Xcode https://developer.apple.co ...