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. JavaWeb-tomcat安装(Unsupported major.minor version 51.0/startup.bat闪退)

    JavaWeb-tomcat安装(Unsupported major.minor version 51.0) 一 启动startup.bat 出错i 今天安装tomcat出错,折腾了一下午,收获了许多 ...

  2. Eureka详解系列(三)--探索Eureka强大的配置体系

    简介 通过前面的两篇博客,我们知道了:什么是 Eureka?为什么使用 Eureka?如何适用 Eureka?今天,我们开始来研究 Eureka 的源码,先从配置部分的源码开始看,其他部分后面再补充. ...

  3. 记angular和asp.net使用grpc进行通信

    AspNetCore配置grpc服务端 新建一个Demo项目: GrpcStartup, 目录结构如下图: GrpcStartup.GrpcServices需要安装下面的依赖 <PackageR ...

  4. [源码分析] Dynomite 分布式存储引擎 之 DynoJedisClient(2)

    [源码分析] Dynomite 分布式存储引擎 之 DynoJedisClient(2) 目录 [源码分析] Dynomite 分布式存储引擎 之 DynoJedisClient(2) 0x00 摘要 ...

  5. 翻译:《实用的Python编程》README

    欢迎光临 大约 25 年前,当我第一次学习 Python 时,发现 Python 竟然可以被高效地应用到各种混乱的工作项目上,我立即被震惊了.15 年前,我自己也将这种乐趣教授给别人.教学的结果就是本 ...

  6. CF Hello2020 D. New Year and Conference

    D. New Year and Conference 题意 有\(2n\)个区间,分别为\([sa_1,ea_1],[sb_1,eb_1],[sa_2,ea_2],[sb_2,eb_2],\cdots ...

  7. hdu 3974 Assign the task(dfs序上线段树)

    Problem Description There is a company that has N employees(numbered from 1 to N),every employee in ...

  8. Codeforces Round #647 (Div. 2) D. Johnny and Contribution(BFS)

    题目链接:https://codeforces.com/contest/1362/problem/D 题意 有一个 $n$ 点 $m$ 边的图,每个结点有一个从 $1 \sim n$ 的指定数字,每个 ...

  9. zoj3545Rescue the Rabbit (AC自动机+状压dp+滚动数组)

    Time Limit: 10 Seconds      Memory Limit: 65536 KB Dr. X is a biologist, who likes rabbits very much ...

  10. IntelliJ IDEA 运行java程序时出现“程序发生找不到或无法加载主类 cn.test1.test1”错误

    在你程序不出现错误,而且你的编译器已经成功导入后 成功导入的样子 你可以重新打开一个项目 这就可以了^_^