SpringBoot2.0之整合ElasticSearch

SpringBoot2.0整合Elasticsearch6.0使用ElasticsearchRepository接口实践 SpringBoot2.0整合Elasticsearch6.0,使用SpringBoot对ES支持ElasticsearchRepository接口API,ElasticsearchTemplate接口API实现ES的增删改查实践 立即下载

SpringBoot2.0之整合ElasticSearch

就类比数据库到时候去实现

服务器端配置 集群名字  与yml名字一致

pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.toov5</groupId>
  <artifactId>springboot-es</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
      <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- springboot 整合es -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
    </dependencies>
  
</project>

项目结构:

Entity:

package com.toov5.entity;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

import lombok.Data;
  
 @Document(indexName="toov5",type="user")   //索引的名字  类型
 @Data 
public class UserEntity {
  @Id    
  private String id;
  private String name;
  private Integer age;
  private Integer sex;
}

Dao:

package com.toov5.dao;

import org.springframework.data.repository.CrudRepository;

import com.toov5.entity.UserEntity;

public interface UserDao extends CrudRepository<UserEntity, String> {

    
    
}

Controller:

package com.toov5.controller;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.toov5.dao.UserDao;
import com.toov5.entity.UserEntity;

@RestController
public class EsController {
    
    @Autowired
    private UserDao userDao;
    
    //添加文档
    @RequestMapping("/addUser")
    public UserEntity addUser(@RequestBody UserEntity userEntity) {
      return userDao.save(userEntity);    
    } 
    
    //查询文档
    @RequestMapping("/findById")
    public Optional<UserEntity> findById(String id) {
       return userDao.findById(id);    
    }
    
}

 

成功:

查看:

 

 

 查询:

 

SpringBoot集成Elasticsearch7.4 实战.pdf 1、CentOS7下安装Elasticsearch7.4 2、SpringBoot版本2.1.8.RELEASE,集成Elasticsearch7.4实现创建索引、删除索引;添加输入 立即下载

相关推荐

springboot整合ElasticSearch集群

springboot 2.0.2集成elasticsearch5.5.1,并使用集群模式,亲测可用!!!

SpringBoot2整合ElasticSearch(包含ElasticSearch入门+spring-boot-starter-data-elasticsearch)

作为互联网热点知识的ElasticSearch,怎能不学。如果你有空余时间,欢迎入门;如果你没空余时间,也欢迎走马观花看一眼。走过如果不要错过,这是一篇自我感觉相对对入门者来说比较全面的文章了,希望对大家有帮助,有什么疑问或者建议欢迎留言讨论。

★【World Of Moshow 郑锴】★ 7372

springboot+elasticsearch,入门最详细的项目

这是一个入门级别的springboot+elasticsearch的项目,内涵增删改查,值得刚入门的大兄弟们学习

springboot 2.0集成elasticsearch 7.6.2(集群)

小伙伴们,你们好呀,我是老寇,跟我一起学习es 7.6.2 注:请点击我,获取源码 目录 一、引入依赖配置pom.xml 二、配置application-dev.yml(生产就克隆application-dev改成生产配置) 三、配置ES注解 四、配置es及swagger 五、ES工具类 (索引相关配置不懂的,请查看elasticsearch 7.6.2 - 索引管理) 七、测试es 一、引入依赖配置pom.xml <dependency>

. 1万+

飞控芯片的隐形战场:传感器冗余与实时OS的可靠性革命

本文深入探讨飞控芯片在工业级无人机中的可靠性设计,聚焦传感器冗余架构与实时操作系统(RTOS)的容错机制。通过多IMU备份、自适应加权融合算法及NuttX、ChibiOS等RTOS的故障隔离技术,确保系统在极端环境下毫秒级自愈。文章还涵盖开源生态如PX4的跨平台移植及RISC-V架构的应用,为高可靠性飞控系统提供关键技术参考。

z5a6b的博客 877

百度网盘开放平台OAuth 2.0授权全流程解析

本文详细解析了百度网盘开放平台OAuth 2.0授权全流程,包括创建应用、获取凭证、授权码模式详解以及access_token的使用与刷新。通过实际案例和代码示例,帮助开发者快速掌握接口调用技巧,避免常见错误,确保安全高效地接入百度网盘API。

wind6的博客 1266

SpringBoot2.0 整合 ElasticSearch框架,实现高性能搜索引擎

本文源码 GitHub:知了一笑 https://github.com/cicadasmile/spring-boot-base 一、安装和简介 ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎...

weixin_30602505的博客 594

Windows非分页缓冲池内存泄漏实战:PoolMon与RAMMap高效排查指南

本文详细介绍了Windows系统中非分页缓冲池内存泄漏的实战排查方法。当系统出现卡顿且内存占用异常增长时,通过RAMMap工具快速定位非分页缓冲池异常,并利用PoolMon监控内核内存分配标签,精准锁定泄漏源。文章提供了从确认症状、安装工具到使用findstr命令溯源驱动文件的完整五步排查流程,并总结了常见泄漏标签与解决方案,帮助用户高效解决深层系统内存问题。

weixin_28455801的博客 1011

SpringBoot 整合 Elasticsearch (超详细)

为了完成 Spring Boot 与 Elasticsearch 整合需要安装下面工具 1.1 Elasticsearch 安装 🔗 Elasticsearch 官网 🔗 Elasticsearch 6.4.3 下载链接 1.2 Elasticsearch ik 安装 🔗 Elasticsearch ik 官网下载地址🔗 Elasticserch ik 6.4.3 版本下载地址 1.3 postman 安装 🔗 Postman 官网下载链接 3. SpingBoot 整合 Elasticsea...

1万+

论文阅读4——一种宽频带圆极化微带天线的设计

论文阅读——一种宽频带圆极化微带天线的设计(现在才觉得开始弄懂了一点,懂了一点之后又更糊涂了……)

weixin_64612422的博客 2317

《QMT量化实战系列》支持自定义筛选与排序的多因子策略,实测年化收益超100%

【QMT量化实战系列】推出《支持自定义筛选与排序的多因子策略》,通过Tushare获取38个核心因子数据,实现股票多维筛选(剔除ST股、次新股及特定板块)。策略创新性地采用多因子加权排名机制,通过(股票数-排名+1)/股票数*100的算法计算各因子得分,支持自定义权重组合。该策略提供完整代码及详细注释,涵盖数据获取、因子筛选、权重排序等核心环节,帮助用户构建个性化量化模型。系列内容每月更新1-2期,由浅入深讲解QMT平台实战应用。

qq_46262068的博客 1255

Springboot2.0整合ElasticSearch

环境搭建 1、maven依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</versi...

小尾寒羊的博客 2373

springboot整合elasticsearch_SpringBoot2.0整合ElasticSearch5.x

1.前言网上很多整合教程都是基于SpringBoot1.5的,而SpringBoot1.5只支持2.x版本的ElasticSearch,而我想要使用5.x系的ES,折腾半天终于弄好了,这里记录一下2.项目环境JDK 1.8Spring Boot 2.0.0.RELEASEElasticSearch 5.6.8Deepin Linux 15.53.搭建SpringBoot骨架用idea创建新项目,勾...

weixin_39625172的博客 259

AUTOSAR AP——SM模块

对AUTOSAR AP中状态管理模块SM,从模块定义、总结等多方面进行了介绍。

weixin_43627682的博客 284

Midscene.js(2):代码集成 + 桥接模式(Bridge Mode)的使用「喂饭教程」

本文将手把手教你从零开始搭建一个 Node.js 项目,集成 Midscene.js,并利用其桥接模式实现对 Chrome 浏览器的自动化操作。我们将通过具体的实例,来展示 Midscene.js 的便捷性与 AI 能力的结合。

blues_C的博客 1844

springboot2.0整合es的异常总结

springboot2.0整合es的异常总结

hijk7的博客 121

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

SpringBoot2.0以上整合elasticsearch报错

遇到的错误· failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{IrKwoPPDRli0TN2PTBqSHg}127.0.0.1...

wssc63262的博客 3587

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

springboot 2.1.5 整合elasticsearch6.3.0

springboot 2.1.5整合elasticsearch6.3.0 安装elasticsearch6.3.0 安装kibana6.3.0 安装ik分词器 springboot 整合es 搭建环境如下: springboot 2.1.5 elasticsearch 版本6.3.0 kibana 版本6.3.0 IK Analyzer for Elasticsearch 版本 6.3.0 如需设置账户密码登录要购买es的商业版 jdk1.8 安装elasticsearch6

m0_67403272的博客 771

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

spring boot 2.0 整合 elasticsearch6.5.3,spring boot 2.0 整合 elasticsearch NoNodeAvailableException...

原文地址:spring boot 2.0 整合 elasticsearch NoNodeAvailableException 原文说的有点问题,下面贴出我的配置: 原码云项目地址:https://gitee.com/11230595/springboot-elasticsearch 我的码云项目地址,在原来基础上进行了修改和优化 elasticsearch.yml cluste...

haoweng4800的博客 450

Springboot2.0整合elasticsearch实现CRUD操作

springboot和elasticsearchd的整合网上有很多例子,要不就是elasticsearch太老,要不就是和springboot版本不匹配报错: org.elasticsearch.transport.NodeDisconnectedException: [][127.0.0.1:9300][cluster:monitor/nodes/liveness] disconnected ...

ding_hua的博客 4441

springboot如何整合elasticsearch8.2.0

springboot如何整合elasticsearch8.2.0

weixin_45592424的博客 1061

搜索框架ElasticSearch介绍和整合SpringBoot2.0

搜索框架ElasticSearch介绍和整合SpringBoot 1、搜索知识和搜索框架elasticsearch介绍 简介:通过京东电商 介绍什么是搜索引擎,和开源搜索框架ElasticSearch6.x新特性介绍 前言:介绍ES的主要特点和使用场景,新特性讲解 mysql:like 模糊,性能问题, solr:针对企业,Lucene elasticsearch:针对数据量特别大,PB...

Java编程基础 313

【Spring Boot 2.0学习之旅-12】搜索框架ElasticSearch介绍和整合SpringBoot

ElasticSearch入门 1.ElasticSearch简介 1.1 什么是ElasticSearch? 基于Apache Lucene构建的开源搜索引擎; 采用Java编写,提供简单易用的 RESTFul API; 轻松的横向扩展,可支持PB级的结构化或非结构化数据处理; 1.2 应用场景 海量数据分析引擎 站内搜索引擎 数据仓库 一线公司实际应用场景: 英国卫报-实时分析公众对文章的回应; 维基百科、Github-站内实时搜索 百度-实时日志监控平台 2.ElasticSearch安装

Mind_programmonkey的博客 2054
上一篇: 使用kibana进行简单的CRUD和版本控制
下一篇: Elasticsearch入门
Art&Code
博客等级 码龄7年 77粉丝 554原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值