springboot之集成Elasticsearch
目录
- 二、Elasticsearch 是什么?
- 三、Elasticsearch 安装
- 四、Springboot 集成 Elasticsearch 的方式
- 五、创建项目集成 Elasticsearch
-
- 2.创建 Spring Initializr 项目 es
-
- (3).新建实体类 User
- (4).新建 dao 接口类 UserRepository
- (5).新建服务接口类 UserService
- (6).新建服务实现类 UserServiceImpl
- (7).新建控制类 UserController
一、前言
网上 springboot 集成 Elasticsearch 的文章很多,但随着 springboot 和 Elasticsearch 版本的不断升级,绝大多数文章使用的集成方式和调用的方法已经过时,几乎找不到能真正适用最新 springboot 版本和最新 Elasticsearch 版本的文章。
本文正是基于最新 springboot 版本和最新 Elasticsearch 版本实现了集成。
二、Elasticsearch 是什么?
Elasticsearch(ES) 是一个基于 Lucene 的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于 RESTful web 接口。Elasticsearch 是用 Java 语言开发的,并作为 Apache 许可条款下的开放源码发布,是一种流行的企业级搜索引擎。Elasticsearch 用于云计算中,能够达到实时搜索、稳定、可靠、快速、安装使用方便。官方客户端在Java、.NET(C#)、PHP、Python、Apache Groovy、Ruby 和许多其他语言中都是可用的。根据 DB-Engines 的排名显示,Elasticsearch 是最受欢迎的企业搜索引擎,其次是 Apache Solr,也是基于 Lucene。
三、Elasticsearch 安装
见 CentOS7和8下安装Elasticsearch 和 ElasticSearch ik分词器的安装使用 。
四、Springboot 集成 Elasticsearch 的方式
1.TransportClient
TransportClient 在 Elasticsearch 7.0.0 中已被弃用,取而代之的是 Java High Level REST Client,并将在 Elasticsearch 8.0中删除。在项目中不再建议使用,详见
官方链接: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-api.html#java-api

2.Java REST Client
Java REST Client 在 Elasticsearch 7.15.0 中已弃用,取而代之的是 Java API Client。在项目中不再建议使用,详见
官方链接: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html

3.Java API Client
官方推荐使用的方式。详见
官方链接: https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html
4.Spring Data Elasticsearch
Spring Data Elasticsearch 项目提供了与 Elasticsearch 搜索引擎的集成。Spring Data Elasticsearch 的关键功能领域是一个以 POJO 为中心的模型,用于与 Elastichsearch 文档进行交互,并轻松编写存储库数据访问层。
本文正是基于 Spring Data Elasticsearch 方式实现 springboot 集成 Elasticsearch。
五、创建项目集成 Elasticsearch
1.项目说明
新建 Spring Initializr 项目 es,项目下新建 controller、entity、dao、service、impl 类,实现对 Elasticsearch 的 CRUD 操作。
项目目录结构:

2.创建 Spring Initializr 项目 es

(1).添加依赖
添加依赖,如果已按截图操作,pom.xml 的内容会自动生成:
<pre class="prettyprint hljs xml" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/>
</parent>
<groupId>com.chaoyue</groupId>
<artifactId>es</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>es</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
</dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><excludes><exclude><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></exclude></excludes></configuration></plugin></plugins>
</build>
</project></pre>
(2).添加配置
application.yml 文件中添加如下配置:
<pre class="prettyprint hljs less" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">server:
port: 8080
spring:
elasticsearch:
uris: 192.168.1.38:9200</pre>
(3).新建实体类 User
为减少不必要的代码,引入 lombok 依赖:
<pre class="prettyprint hljs xml" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency></pre>
实体类代码如下:
<pre class="prettyprint hljs kotlin" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">package com.chaoyue.es.entity;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
@Data
@Document(indexName = "user")
public class User implements Serializable {
@Id
private String id; // id
private String username; // 用户名
private String password; // 密码
}</pre>
(4).新建 dao 接口类 UserRepository
<pre class="prettyprint hljs css" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">package com.chaoyue.es.dao;
import com.chaoyue.es.entity.User;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends ElasticsearchRepository<User, String> {
}</pre>
(5).新建服务接口类 UserService
<pre class="prettyprint hljs java" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">package com.chaoyue.es.service;
import com.chaoyue.es.entity.User;
public interface UserService {
User save(User user);
void delete(User user);
Iterable<User> getAll();
}</pre>
(6).新建服务实现类 UserServiceImpl
<pre class="prettyprint hljs css" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">package com.chaoyue.es.service.impl;
import com.chaoyue.es.dao.UserRepository;
import com.chaoyue.es.entity.User;
import com.chaoyue.es.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserRepository userRepository;@Override
public User save(User user) { return userRepository.save(user);
}@Override
public void delete(User user) { userRepository.delete(user);
}@Override
public Iterable<User> getAll() { return userRepository.findAll();
}
}</pre>
(7).新建控制类 UserController
<pre class="prettyprint hljs kotlin" style="padding: 0.5em; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; color: rgb(68, 68, 68); border-radius: 4px; display: block; margin: 0px 0px 1.5em; font-size: 14px; line-height: 1.5em; word-break: break-all; overflow-wrap: break-word; white-space: pre; background-color: rgb(246, 246, 246); border: none; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">package com.chaoyue.es.controller;
import com.chaoyue.es.entity.User;
import com.chaoyue.es.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;@RequestMapping("/insert")
public String insert() { User user = new User();user.setId("1");user.setUsername("张三");user.setPassword("zhangsan");userService.save(user);return getAll();
}@RequestMapping("/delete")
public String delete() { User user = new User();user.setId("1");userService.delete(user);return getAll();
}@RequestMapping("/getAll")
public String getAll() { List<User> list = new ArrayList<>();Iterable<User> iterable = userService.getAll();iterable.forEach(e->list.add((User) e));return list.toString();
}
}</pre>
3.启动服务并测试
启动服务后,浏览器输入:http://localhost:8080/user/insert,会新增一条 id 为 “1” 的记录:

浏览器输入:http://localhost:8080/user/delete,会删除一条 id 为 “1” 的记录:

浏览器输入:http://localhost:8080/user/getAll,会显示所有记录:


喜欢的朋友记得点赞、收藏、关注哦!!!
相关文章:
springboot之集成Elasticsearch
目录 二、Elasticsearch 是什么?三、Elasticsearch 安装四、Springboot 集成 Elasticsearch 的方式五、创建项目集成 Elasticsearch 2.创建 Spring Initializr 项目 es (3).新建实体类 User(4).新建 dao 接口类 UserRe…...
CLIP (Contrastive Language-Image Pre-training)用途及使用方法
CLIP (Contrastive Language-Image Pre-training) 是由 OpenAI 开发的多模态模型,可以同时处理图像和文本。在 Hugging Face 中使用 CLIP 模型主要有以下几个步骤和用途: 安装必要的库: pip install transformers pip install torch pip install Pillow导入所需模…...
2018年西部数学奥林匹克几何试题
2018G1 未完待续… 2018 G2 在 △ A B C \triangle ABC △ABC 中, E E E, F F F 分别在 A B AB AB, A C AC AC 上, 且 B F C E B C BFCEBC BFCEBC. I B I_B IB, I C I_C IC 分别为 ∠ A B C \angle ABC ∠ABC 和 ∠ A C B \angle ACB ∠ACB 所对的旁心, K K…...
华为配置 之 链路聚合
简介: 链路聚合(Link Aggregation)是一种计算机网络技术,通过将多个物理端口汇聚在一起,形成一个逻辑端口,以实现出/入流量吞吐量在各成员端口的负荷分担。当交换机检测到其中一个成员端口的链路发生故障时…...
MIT线性代数教材:Linear Algebra and Its Applications
这本教材是MIT线性代数课程所使用的教材,上课的老师是Gilbert Strang,而教材的作者也是Gilbert Strang。这本书内容比较直观,配图不少,叙述风格比较几何风格。习题也丰富,但并不怎么对我的胃口,因此我也怎么…...
SpringBoot 集成 Activiti 7 工作流引擎
一. 版本信息 IntelliJ IDEA 2023.3.6JDK 17Activiti 7 二. IDEA依赖插件安装 安装BPM流程图插件,如果IDEA的版本超过2020,则不支持actiBPM插件。我的IDEA是2023版本我装的是 Activiti BPMN visualizer 插件。 在Plugins 搜索 Activiti BPMN visualizer 安装 创…...
【数据结构】数据结构简要介绍
数据结构是计算机科学中用于组织、管理和存储数据的方式,以便于高效地访问和修改数据。 数据结构的分类: 数据结构可以大致分为两类:线性结构和非线性结构。 1. 线性结构 线性结构中的数据按顺序排列,每个元素有唯一的前驱和后…...
SQL Server导出和导入可选的数据库表和数据,以sql脚本形式
一、导出 1. 打开SQL Server Management Studio,在需要导出表的数据库上单击右键 → 任务 → 生成脚本 2. 在生成脚本的窗口中单击进入下一步 3. 如果只需要导出部分表,则选择第二项**“选择具体的数据库对象(Select specific database objects)”**&am…...
蓝桥杯JAVA刷题--001
文章目录 题目需求2.代码3.总结 题目需求 2.代码 class Solution {public String convertDateToBinary(String date) {if (date null || date.length() ! 10 || date.charAt(4) ! - || date.charAt(7) ! -) {throw new IllegalArgumentException("输入的日期格式不正确&…...
2025-01-01 NO2. XRHands 介绍
文章目录 软件配置1 XR Hands 简介2 XRHand2.1 Pose2.2 Handedness 3 XRHandJoint3.1 XRHandJointID3.2 XRHandJointTrackingState 4 XRHandSubsystem4.1 数据属性4.1.1 UpdateSuccessFlags4.1.2 UpdateType 4.2 处理器管理:注册和注销4.3 更新手部数据:…...
SQL 实战:复杂数据去重与唯一值提取
在实际开发中,数据重复是常见问题,例如用户多次登录记录、订单状态重复更新等。如何高效提取符合业务需求的唯一值或最新记录,对系统性能和数据准确性至关重要。 本文将探讨如何使用 SQL 的 窗口函数、分组查询 以及 DISTINCT 实现复杂场景下…...
基于BiLSTM和随机森林回归模型的序列数据预测
本文以新冠疫情相关数据集为案例,进行新冠数量预测。(源码请留言或评论) 首先介绍相关理论概念: 序列数据特点 序列数据是人工智能和机器学习领域的重要研究对象,在多个应用领域展现出独特的特征。这种数据类型的核心特点是 元素之间的顺序至关重要 ,反映了数据内在的时…...
基于 SensitiveWordBs 实现敏感词过滤功能
在现代的互联网应用中,敏感词过滤已成为一个必不可少的功能,尤其是在社交媒体、评论审核等需要保证内容健康的场景下。本文将基于开源库https://github.com/houbb/sensitive-word,详细讲解如何通过自定义敏感词库和工具类实现高效的敏感词过滤…...
计算机的错误计算(一百九十八)
摘要 用两个大模型计算 arctan(54.321). 结果保留 16位有效数字。第一个大模型化简有误差;第二个大模型 Python代码几乎完全正确。无论如何,它们的结果均只有 4位数字正确。 例1. 计算 arctan(54.321). 结果保留 16位有效数字。 下面是一个大模型的回…...
递归算法.
本节我们先来了解一下递归算法. 递归算法的基本原理: 说到递归算法,就不得不提到栈.当程序执行到递归函数的时候,将函数进行入栈操作,在入栈之前,通常需要完成3件事. 1.将所有实参,返回地址等信息传递给被调函数储存 2.为被调函数的局部变量分配储存区 3.将控制转移到被调函…...
我的Java-Web进阶--SpringMVC
1.三层架构与MVC模式 三层架构 MVC模式 2.SpringMVC执行流程 3.SpringMVC的基本使用方法 1. 配置 1.1 Maven依赖 首先,在pom.xml文件中添加Spring MVC的依赖: <dependencies><!-- Spring MVC --><dependency><groupId>org.…...
【复刻】ESG表现对企业价值的影响机制研究(2009-2021年)
一、数据来源:ESG数据采用华证ESG评价体系提供的评级结果,控制变量主要来自上市公司年报,内含原始数据、处理代码和基准回归 二、数据指标:资产收益率 净利润 / 平均总资产销售净利率 净利润 / 营业收入托宾Q值 …...
GSM PDU解码在Linux下的C语言实现
GSM PDU解码在Linux下的C语言实现 一、引言二、GSM PDU格式概述三、Linux环境下的C语言实现(一)头文件包含(二)数据结构定义(三)解码函数实现(四)主函数示例四、编译与运行五、注意事项与优化六、结论一、引言 GSM(全球移动通信系统)PDU(协议数据单元)是用于在GSM…...
Vue 3.0 中 template 多个根元素警告问题
在 Vue 2.0 中,template 只允许存在一个根元素,但是这种情况在 Vue 3.0 里发生了一些变化。 在 Vue 3.0 中开始支持 template 存在多个根元素了。但是因为 VSCode 中的一些插件没有及时更新,所以当你在 template 中写入多个根元素时…...
STM32F103RCT6学习之三:串口
1.串口基础 2.串口发送 1)基本配置 注意:实现串口通信功能需在keil中设置打开Use Micro LIB,才能通过串口助手观察到串口信息 2)编辑代码 int main(void) {/* USER CODE BEGIN 1 *//* USER CODE END 1 *//* MCU Configuration-------------…...
07-计算机网络面试实战
07-计算机网络面试实战 计算机网络面试实战 为什么要学习网络相关知识? 对于好一些的公司,计算机基础的内容是肯定要面的,尤其是 30k 以内的工程师,因为目前处于的这个级别肯定是要去写项目的,还没上升到去设计架构的高…...
Kafka的acks机制和ISR列表
Kafka 是一个流行的分布式流处理平台,用于构建实时数据流管道和应用程序。在 Kafka 中,acks 机制和 ISR(In-Sync Replicas)列表是两个重要的概念,它们共同确保消息的持久性和可靠性。 acks 机制 acks 机制是 Kafka 生…...
c++Qt登录页面设计
使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数 将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为…...
数字图像处理 四 图像统计
1.直方图 记录每一种像素值出现的次数 各种直方图的类型 暗图像:分布靠低值区域 亮图像:分布靠高值区域 高对比度图像,直方图分布均匀,更容易人眼观察 2.直方图的均衡化 将低对比度图像转换为高对比度图像 视觉良好的直方图…...
UE蓝图类调用关卡蓝图中的函数
蓝图类调用关卡蓝图中函数 需要用到Execute Console Command函数节点 ce空格【函数名】 在关卡蓝图中创建一个函数sayhello 在第三人称蓝图类中调用 成功输出 注:用此方法只能从蓝图类中调用关卡蓝图中的函数,从关卡蓝图调用蓝图类是无效的。 另外Exec…...
JAVA: 状态模式(State Pattern)的技术指南
1、简述 状态模式是一种行为型设计模式,允许对象在其内部状态改变时改变其行为。它将状态相关的行为抽取到独立的状态类中,使得增加新状态变得简单,且不影响其他状态。 设计模式样例:https://gitee.com/lhdxhl/design-pattern-example.git 本文将详细介绍状态模式的概念…...
C语言:位段
位段的内存分配: 1. 位段的成员可以是 int unsigned int signed int 或者是char (属于整形家族)类型 2. 位段的空间上是按照需要以4个字节( 类型 int )或者1个字节( char )的方式来开辟的。 3. 位段涉及…...
数字图像处理 三 空间滤波
空间滤波是一种图像处理技术,它通过对图像像素及其邻域进行运算,利用均值,高斯,梯度,拉普拉斯等线性滤波和中值,最大最小,双边滤波等非线性滤波改变像素值,实现图像的平滑࿰…...
创建线程的8种方法
创建线程的8种方法 目录 继承Thread类实现Runnable接口实现Callable接口使用线程池使用ScheduledExecutorService使用Fork/Join框架使用CompletableFuture使用Guava的ListenableFuture总结 1. 继承Thread类 最直接的方式是创建一个继承自Thread类的子类,并重写其r…...
[项目管理] 不求甚解
前两天总结了一个例子:https://mzhan017.blog.csdn.net/article/details/144768130; 在上一篇里末尾处,说有一个情况是openstack的问题,接着这个事情来继续说。产品安装的时候需要一个对外的IP/网络,是测试/设备人员通…...
JetBrains《2024 开发者生态系统现状报告》总结
JetBrains 公布了 2024 年《开发者生态系统状况报告》,基于全球 23262 名开发者的反馈。编程语言趋势: JavaScript 的使用率: 尽管 JavaScript 仍是最常用的编程语言,61% 的开发者用于网页开发,但其作为主要语言的用户…...
locate() 在MySQL中的用法
语法: 在MySQL中,LOCATE() 是一个字符串函数,用于返回一个子字符串在另一个字符串中第一次出现的位置。如果子字符串不存在,则返回0。这个函数的语法如下: LOCATE(substring, string[, start])substring:…...
数字图像处理 六 频率域
频率:信号进行周期性变化的速率 图像的频率:图像的亮度/颜色在水平/垂直方向上周期性变化的速率 1.傅里叶变换 图像从空间域到频率域的转换: 确定某种频率:选择信号的基,且通过基的组合可以表示其他任何信号&#…...
day21-ubuntu入门
小趣味docker 1.安装docker,从阿里云的yum yum install docker -y 2.需要提前准备好docker镜像,确保可用 docker -v 3.导入该游戏镜像(先用systemctl start docker) docker load < game_v2.tar 4.一条命令,在…...
Linux之ARM(MX6U)裸机篇----4.C语言LED驱动实验
一,启动文件 .global _start_start:设置处理器进入SVC模式mrs r0, cpsr 读取cpsr到r0bic r0, r0, #0x1f 清除cpsr的bit4-0orr r0, r0, #0x13 使用svc模式msr cpsr, r0 将r0写入到cpsrldr sp, 0x80200000 设置sp指针起始地址,此处已初…...
TCP 连接:三次握手与四次挥手
TCP 协议,全称为“传输控制协议”。 1. TCP 协议段格式 给出几个定义 : 16位源端口号 :用于标识发送端的应用程序。 16位目的端口号 :用于标识接收端的目标应用程序。 32位序号 :用于标识发送的每一个字节流中的第一…...
Mac、Linux命令
Linux 查本机IP:ip addr 查询文件里符合条件的字符串:grep Mac 查本机IP:ipconfig...
基于 `android.accessibilityservice` 的 Android 无障碍服务深度解析
基于 android.accessibilityservice 的 Android 无障碍服务深度解析 目录 引言无障碍服务概述架构设计核心功能设计模式核心要点实现细节性能优化安全与隐私案例分析未来展望结论引言 在当今的移动应用生态系统中,无障碍服务(Accessibility Service)扮演着至关重要的角色。…...
spring boot 异步线程池的使用
创建Spring Boot项目 首先,你需要创建一个Spring Boot项目。你可以使用Spring Initializr(https://start.spring.io/)来快速生成项目结构。 添加异步支持依赖 在你的pom.xml文件中,确保你已经添加了Spring Boot的starter依赖&…...
简单封装线程库 + 理解LWP和TID
文章目录 前言:简单封装一下C线程库如何理解tid?理解pthread库:内核视角与用户视角: 前言: 在上一文的线程控制中,我们先是聊了关于为什么我们要在编译链接时将线程库给链接起来,简单回顾一下&…...
VBA批量插入图片到PPT,一页一图
Sub InsertPicturesIntoSlides()Dim pptApp As ObjectDim pptPres As ObjectDim pptSlide As ObjectDim strFolderPath As StringDim strFileName As StringDim i As Integer 设置图片文件夹路径strFolderPath "C:\您的图片文件夹路径\" 请替换为您的图片文件夹路径…...
cjson——excel转json文件(python脚本转换)
excel转json文件 前言应用场景1. 安装必要的库2. 定义 Excel 表格格式3. Python 脚本:将 Excel 转换为 JSON4. 脚本解释5. 生成的 JSON 文件6. 如何使用 JSON 文件7. 扩展功能:处理多个工作表8. 总结 前言 将 Excel 表格的配置参数转换成 JSON 文件是一…...
Keepalived + LVS 搭建高可用负载均衡及支持 Websocket 长连接
一、项目概述 本教程旨在助力您搭建一个基于 Keepalived 和 LVS(Linux Virtual Server)的高可用负载均衡环境,同时使其完美适配 Websocket 长连接场景,确保您的 Web 应用能够高效、稳定地运行,从容应对高并发访问&…...
01-spring-理-beanFactory
需要掌握 拿到容器中的 实例这个可以debug IOC容器SpringBootApplication(exclude {DataSourceAutoConfiguration.class}) public class RuoYiApplication {public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {// System.setProp…...
【pytorch】卷积神经网络
1 图像卷积 1.1 互相关运算 在二维互相关运算中,卷积窗口从输入张量的左上角开始,从左到右、从上到下滑动。当卷积窗口滑动到新一个位置时,包含在该窗口中的部分张量与卷积核张量进行按元素相乘,得到的张量再求和得到一个单一的标…...
强大的接口测试可视化工具:Postman Flows
Postman Flows是一种接口测试可视化工具,可以使用流的形式在Postman工作台将请求接口、数据处理和创建实际流程整合到一起。如下图所示 Postman Flows是以API为中心的可视化应用程序开发界面。它提供了一个无限的画布用于编排和串连API,数据可视化来显示…...
RISCV学习(3)HPM5301 MCU芯片学习
RISCV学习(3)HPM5301 MCU芯片学习 1、HPM5301 背景介绍 笔者在RT-Thread开发者大会上领了一个HPM5301EVKLite的盲盒板子,就抽空点个灯介绍一下。主要板子如下图所述,类似于一个最小系统板。 开发厂商:先楫半导体,HPMICRO芯片架构:32位的RISC-V,RV32,支持IMAFDCPB指…...
拆解 | 公募REITs:发售上市流程及细节
Hi,围炉喝茶聊产品的新老朋友好,在国庆假期写了两篇有关公募REITs的文章,先简单回顾下,以达到温故知新的效果。 第一篇:一起探索:公募REITs,它从本质、背景、概念等维度较系统介绍了公募REITs,如:明明是“不动产基金”,为什么叫REITs?说到底,投资REITs的实质是什么…...
嵌入式系统 第七讲 ARM-Linux内核
• 7.1 ARM-Linux内核简介 • 内核:是一个操作系统的核心。是基于硬件的第一层软件扩充, 提供操作系统的最基本的功能,是操作系统工作的基础,它负责管理系统的进程、内存、设备驱动程序、文件和网络系统, 决定着系统的…...
记一次 dockerfile 的循环依赖错误
文章目录 1. 写在最前面1.1 具体循环依赖的例子 2. 报错的位置2.1 代码快速分析2.2 代码总结2.3 关于 parser 的记录 3. 碎碎念 1. 写在最前面 笔者在使用 dockerfile 多阶段构建的功能时,写出了一个「circular dependency detected on stage: xx」的错误。 解决方…...