当前位置: 首页 > news >正文

Elasticsearch封装公共索引增删改查

 什么是索引?

  • 定义:索引是 Elasticsearch 中用于存储数据的逻辑命名空间。它由多个文档组成,每个文档是一个 JSON 格式的结构化数据
  • 对应关系:在关系数据库中,索引类似于表;而在 Elasticsearch 中,索引则相当于数据库的集合或目录。

依赖

        选择方案一

                 使用这个依赖的话必须搭配配置类去使用

 <!-- elasticsearch --><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>7.7.0</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>7.7.0</version></dependency>

        选择方案二


            使用这个依赖的话配置类可写可不写,因为springboot工程已经帮我们自动的去完成配置了,不需要我们自己写了

               

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

配置

es:host: 111.229.0.43port: 9200scheme: http

配置类

package com.macro.mall.demo.config;import lombok.Data;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;@Data
@Component
public class InitEsRes {@Value("${es.host}")private String host;@Value("${es.port}")private int port;@Value("${es.scheme}")private String scheme;@Beanpublic RestHighLevelClient restHighLevelClient(){return new RestHighLevelClient(RestClient.builder(new HttpHost(host,port,scheme)));}
}

dto

package com.macro.mall.demo.dto;import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;/*** @Author:xsp* @Description: es索引传输对象* @name:EsIndexDto* @Date:2024/10/16 15:30*/
@Data
public class EsIndexDto {/*** 索引名称*/@NotEmpty(message = "索引名称不能为空")@ApiModelProperty(value = "索引名称", required = true, example = "。。。。")private String indexName;/*** 索引映射*/@ApiModelProperty(value = "索引映射", required = true, example = "。。。。")private String indexMappings;/*** 索引配置*/@ApiModelProperty(value = "索引配置", required = true, example = "。。。。")private String indexSettings;}

controller

package com.macro.mall.demo.controller;import com.macro.mall.common.api.CommonResult;
import com.macro.mall.demo.dto.EsIndexDto;
import com.macro.mall.demo.service.EsIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import java.util.Map;/*** @Author:xsp* @Description: es索引管理* @name:EsController* @Date:2024/10/15 20:38*/
@RestController
@RequestMapping("/index")
@Validated
@Api(tags = "es索引管理")
public class EsIndexController {@Autowiredprivate EsIndexService esIndexService;/*** 创建索引的接口* @param esIndexDto 索引信息* @return*/@ApiOperation(value = "创建索引")@PostMapping("/create")public CommonResult createIndex(@Validated @RequestBody EsIndexDto esIndexDto) {esIndexService.createIndex(esIndexDto);return CommonResult.successMessage("索引创建成功"); // 调用服务方法创建索引}/*** 删除索引的接口* @param indexName 索引名称* @return*/@ApiOperation(value = "删除索引")@DeleteMapping("/delete")public CommonResult deleteIndex(@RequestParam @NotEmpty(message = "索引名称不能为空") String indexName) {esIndexService.deleteIndex(indexName); // 调用服务方法删除索引return CommonResult.successMessage("索引删除成功");}/***  获取索引的接口* @param indexName 索引名称* @return*/@ApiOperation(value = "获取索引映射")@GetMapping("/get")public CommonResult<Map<String, Object>> getIndex(@RequestParam  @NotEmpty(message = "索引名称不能为空") String indexName) {Map<String, Object> indexMappings = esIndexService.getIndex(indexName);return CommonResult.success(indexMappings); // 调用服务方法获取索引}/*** 根据索引名称修改索引配置* @param esIndexDto 索引信息* @return*/@ApiOperation(value = "修改索引配置")@PutMapping("/update")public CommonResult updateIndex(@Validated @RequestBody EsIndexDto esIndexDto) {esIndexService.updateIndex(esIndexDto);return CommonResult.successMessage("索引更新成功"); // 调用服务方法更新索引}/*** 判断索引是否存在* @param indexName 索引名称* @return*/@ApiOperation(value = "判断索引是否存在")@GetMapping("/exists")public CommonResult exists(@RequestParam  @NotEmpty(message = "索引名称不能为空") String indexName) {boolean exists =esIndexService.exists(indexName);return CommonResult.success(exists);}
}

serveice

package com.macro.mall.demo.service;import com.macro.mall.demo.dto.EsDocDto;
import com.macro.mall.demo.dto.EsIndexDto;import java.util.List;
import java.util.Map;/*** @Author:xsp* @Description:* @name:EsService* @Date:2024/10/15 20:39*/
public interface EsDocService {/*** 批量添加* @param esDocDto 文档信息*/void batchAdd(EsDocDto esDocDto);/*** 批量删除* @param indexName 索引名称* @param ids 多个id*/void batchDelete(String indexName,  List<String> ids);
}

impl

package com.macro.mall.demo.service.impl;import com.macro.mall.demo.dto.EsDocDto;
import com.macro.mall.demo.dto.EsIndexDto;
import com.macro.mall.demo.service.EsIndexService;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import org.elasticsearch.common.xcontent.XContentType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.Map;/*** @Author:xsp* @Description:* @name:EsServiceImpl* @Date:2024/10/15 20:39*/
@Service
@Slf4j
public class EsIndexServiceImpl implements EsIndexService {@Autowiredprivate RestHighLevelClient restHighLevelClient;/*** 创建索引** @param esIndexDto 索引信息*/@Overridepublic void createIndex(EsIndexDto esIndexDto) {// 检查索引是否已存在if (exists(esIndexDto.getIndexName())) {throw new RuntimeException("索引已经存在: " + esIndexDto.getIndexName());}// 创建索引请求CreateIndexRequest request = new CreateIndexRequest(esIndexDto.getIndexName());// 设置索引配置if (StringUtils.isNotBlank(esIndexDto.getIndexMappings())) {request.settings("_doc",esIndexDto.getIndexMappings(), XContentType.JSON);}// 执行创建索引操作try {restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);log.info("索引创建成功: {}", esIndexDto.getIndexName());} catch (Exception e) {log.error("创建索引失败, 错误信息: {}", e.getMessage());throw new RuntimeException("创建索引失败: " + esIndexDto.getIndexName(), e);}}/*** 删除索引** @param indexName 索引名称*/@Overridepublic void deleteIndex(String indexName) {// 检查索引是否存在if (!exists(indexName)) {throw new RuntimeException("索引不存在: " + indexName);}// 创建删除索引请求DeleteIndexRequest request = new DeleteIndexRequest(indexName);// 执行删除索引操作try {restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);log.info("索引删除成功: {}", indexName);} catch (Exception e) {log.error("删除索引失败, 错误信息: {}", e.getMessage());throw new RuntimeException("删除索引失败: " + indexName, e);}}/*** 获取索引映射** @param indexName 索引名称* @return 索引映射信息*/@Overridepublic Map<String, Object> getIndex(String indexName) {// 检查索引是否存在if (!exists(indexName)) {throw new RuntimeException("索引不存在: " + indexName);}// 创建获取索引请求GetIndexRequest request = new GetIndexRequest(indexName);// 执行获取索引映射操作try {GetIndexResponse response = restHighLevelClient.indices().get(request, RequestOptions.DEFAULT);log.info("获取索引映射成功: {}", indexName);return response.getMappings().get(indexName).sourceAsMap(); // 返回索引映射} catch (Exception e) {log.error("获取索引映射失败, 错误信息: {}", e.getMessage());throw new RuntimeException("获取索引映射失败: " + indexName, e);}}/*** 更新索引配置** @param esIndexDto 索引信息*/@Overridepublic void updateIndex(EsIndexDto esIndexDto) {// 检查索引是否存在if (!exists(esIndexDto.getIndexName())) {throw new RuntimeException("索引不存在: " + esIndexDto.getIndexName());}// 创建更新索引设置请求UpdateSettingsRequest request = new UpdateSettingsRequest(esIndexDto.getIndexName());// 更新索引映射if (StringUtils.isNotBlank(esIndexDto.getIndexMappings())) {request.settings(esIndexDto.getIndexMappings(), XContentType.JSON);}// 执行更新索引设置操作try {boolean acknowledged = restHighLevelClient.indices().putSettings(request, RequestOptions.DEFAULT).isAcknowledged();if (acknowledged) {log.info("索引设置更新成功: {}", esIndexDto.getIndexName());} else {log.warn("索引设置更新未被确认: {}", esIndexDto.getIndexName());}} catch (Exception e) {log.error("更新索引设置失败, 错误信息: {}", e.getMessage());throw new RuntimeException("更新索引设置失败: " + esIndexDto.getIndexName(), e);}}/*** 判断索引是否存在** @param indexName 索引名称* @return 索引是否存在*/@Overridepublic boolean exists(String indexName) {// 创建获取索引请求GetIndexRequest request = new GetIndexRequest(indexName);try {// 执行获取索引操作并返回索引是否存在boolean exists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);log.info("判断索引是否存在: {}, 结果: {}", indexName, exists);return exists;} catch (Exception e) {log.error("判断索引是否存在失败, 错误信息: {}", e.getMessage());return false; // 返回判断失败}}}

统一结果集

package com.macro.mall.common.api;import cn.hutool.json.JSONUtil;/*** 通用返回对象* Created by 9a8204a7-f77d-4ab8-ae70-b4721fef2f95 on 2019/4/19.*/
public class CommonResult<T> {private long code;private String message;private T data;protected CommonResult() {}protected CommonResult(long code, String message, T data) {this.code = code;this.message = message;this.data = data;}/*** 成功返回信息* @param message 提示信息*/public static <T> CommonResult<T> successMessage(String message) {return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, null);}/*** 成功返回结果** @param data 获取的数据*/public static <T> CommonResult<T> success(T data) {return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);}/*** 成功返回结果** @param data 获取的数据* @param  message 提示信息*/public static <T> CommonResult<T> success(T data, String message) {return new CommonResult<T>(ResultCode.SUCCESS.getCode(), message, data);}/*** 失败返回结果* @param errorCode 错误码*/public static <T> CommonResult<T> failed(IErrorCode errorCode) {return new CommonResult<T>(errorCode.getCode(), errorCode.getMessage(), null);}/*** 失败返回结果* @param errorCode 错误码* @param message 错误信息*/public static <T> CommonResult<T> failed(IErrorCode errorCode,String message) {return new CommonResult<T>(errorCode.getCode(), message, null);}/*** 失败返回结果* @param message 提示信息*/public static <T> CommonResult<T> failed(String message) {return new CommonResult<T>(ResultCode.FAILED.getCode(), message, null);}/*** 失败返回结果*/public static <T> CommonResult<T> failed() {return failed(ResultCode.FAILED);}/*** 参数验证失败返回结果*/public static <T> CommonResult<T> validateFailed() {return failed(ResultCode.VALIDATE_FAILED);}/*** 参数验证失败返回结果* @param message 提示信息*/public static <T> CommonResult<T> validateFailed(String message) {return new CommonResult<T>(ResultCode.VALIDATE_FAILED.getCode(), message, null);}/*** 未登录返回结果*/public static <T> CommonResult<T> unauthorized(T data) {return new CommonResult<T>(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), data);}/*** 未授权返回结果*/public static <T> CommonResult<T> forbidden(T data) {return new CommonResult<T>(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), data);}public long getCode() {return code;}public void setCode(long code) {this.code = code;}public String getMessage() {return message;}public void setMessage(String message) {this.message = message;}public T getData() {return data;}public void setData(T data) {this.data = data;}@Overridepublic String toString() {return JSONUtil.toJsonStr(this);}
}

这里我用的是这个统一结果集,结合自己实际情况去使用相对应的统一结果集

Spring原生效验异常

    @ResponseBody@ExceptionHandler(value = ApiException.class)public CommonResult handle(ApiException e) {if (e.getErrorCode() != null) {return CommonResult.failed(e.getErrorCode());}return CommonResult.failed(e.getMessage());}@ResponseBody@ExceptionHandler(value = MethodArgumentNotValidException.class)public CommonResult handleValidException(MethodArgumentNotValidException e) {BindingResult bindingResult = e.getBindingResult();String message = null;if (bindingResult.hasErrors()) {FieldError fieldError = bindingResult.getFieldError();if (fieldError != null) {message = fieldError.getField()+fieldError.getDefaultMessage();}}return CommonResult.validateFailed(message);}@ResponseBody@ExceptionHandler(value = BindException.class)public CommonResult handleValidException(BindException e) {BindingResult bindingResult = e.getBindingResult();String message = null;if (bindingResult.hasErrors()) {FieldError fieldError = bindingResult.getFieldError();if (fieldError != null) {message = fieldError.getField()+fieldError.getDefaultMessage();}}return CommonResult.validateFailed(message);}/*** 最大异常* @param e* @return*/@ResponseBody@ExceptionHandler(value = Exception.class)public CommonResult handle(Exception e) {e.printStackTrace();return CommonResult.validateFailed(e.getMessage());}

这里我是用的这几个写的异常捕获器,结合自己实际情况去使用相对应的异常捕获
 

目前先更新到这里,后期补发

相关文章:

Elasticsearch封装公共索引增删改查

什么是索引&#xff1f; 定义&#xff1a;索引是 Elasticsearch 中用于存储数据的逻辑命名空间。它由多个文档组成&#xff0c;每个文档是一个 JSON 格式的结构化数据对应关系&#xff1a;在关系数据库中&#xff0c;索引类似于表&#xff1b;而在 Elasticsearch 中&#xff0…...

Python异常检测:Isolation Forest与局部异常因子(LOF)详解

这里写目录标题 Python异常检测&#xff1a;Isolation Forest与局部异常因子&#xff08;LOF&#xff09;详解引言一、异常检测的基本原理1.1 什么是异常检测&#xff1f;1.2 异常检测的应用场景 二、Isolation Forest2.1 Isolation Forest的原理2.1.1 算法步骤 2.2 Python实现…...

Git的原理和使用(二)

1. git的版本回退 之前我们也提到过&#xff0c;Git 能够管理⽂件的历史版本&#xff0c;这也是版本控制器重要的能⼒。如果有⼀天你发现 之前前的⼯作做的出现了很⼤的问题&#xff0c;需要在某个特定的历史版本重新开始&#xff0c;这个时候&#xff0c;就需要版本 回退的功能…...

docker 发布镜像

如果要推广自己的软件&#xff0c;势必要自己制作 image 文件。 1 制作自己的 Docker 容器 基于 centos 镜像构建自己的 centos 镜像&#xff0c;可以在 centos 镜像基础上&#xff0c;安装相关的软件&#xff0c;之后进行构建新的镜像。 1.1 dockerfile 文件编写 首先&…...

投了15亿美元,芯片创新公司Ampere为何成了Oracle真爱?

【科技明说 &#xff5c; 科技热点关注】 一个数据库软件公司却想要操控一家芯片厂商&#xff0c;这样的想法不错。也真大胆。 目前&#xff0c;全球数据库巨头甲骨文Oracle已经持有Ampere Computing LLC 29%的股份&#xff0c;并有可能通过未来的投资选择权获得对这家芯片制造…...

vue 报告标题时间来自 elementUI的 el-date-picker 有开始时间和结束时间

要在Vue中使用 Element UI 的 el-date-picker 来选择开始时间和结束时间&#xff0c;并将其展示在报告中&#xff0c;以下是详细的实现步骤。 实现思路&#xff1a; 使用 Element UI 的 el-date-picker 组件&#xff0c;让用户选择时间范围&#xff08;开始时间和结束时间&am…...

简单几何问题的通解

来&#xff0c;这道题怎么做&#xff1f;边长为2的正方形内&#xff0c;2个扇形的交集面积是多少&#xff1f;这道题一定要画辅助线&#xff0c;因为要用到两个扇形的交点&#xff0c;如果不画辅助线&#xff0c;这个交点相关的4个子图一个都无法求出面积&#xff0c;只能求出子…...

DBeaver导出数据表结构和数据,导入到另一个环境数据库进行数据更新

在工作中&#xff0c;我们会进行不同环境之间数据库的数据更新&#xff0c;这里使用DBeaver导出新的数据表结构和数据&#xff0c;并执行脚本&#xff0c;覆盖另一个环境的数据库中对应数据表&#xff0c;完成数据表的更新。 一、导出 右键点击选中想要导出的数据表&#xff0…...

【Golang】合理运用泛型,简化开发流程

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…...

OpenCV单目相机内参标定C++

基于OpenCV 实现单目相机内参标定&#xff1a; a.使用OpenCV库实现内参标定过程。通过角点检测、亚像素角点定位、角点存储与三维坐标生成和摄像机标定分别获取左右相机的内参。 b.具体地&#xff0c;使用库函数检测两组图像&#xff08;左右相机拍摄图像&#xff09;中棋盘格…...

基于MATLAB(DCT DWT)

第三章 图像数字水印的方案 3.1 图像数字水印的技术方案 在数据库中存储在国际互联网上传输的水印图像一般会被压缩&#xff0c;有时达到很高的压缩比。因此&#xff0c;数字水印算法所面临的第一个考验就是压缩。JPEG和EZW&#xff08;Embedded Zero-Tree Wavelet&#xff0…...

渗透基础-rcube_webmail版本探测

简介 本文介绍了开源产品RoundCube webmail邮件系统的版本探测思路&#xff0c;并用go语言实现工具化、自动化探测。 正文 0x01 探测思路研究 探测系统版本&#xff0c;最理想的方法就是系统主页html代码中有特定的字符串&#xff0c;比如特定版本对应的hash在主页的html代…...

linux下编译鸿蒙版boost库

我在上一篇文章中介绍了curl和openssl的编译方式&#xff08;linux下编译鸿蒙版curl、openssl-CSDN博客&#xff09;&#xff0c;这篇再介绍一下boost库的编译。 未经许可&#xff0c;请勿转载&#xff01; 一.环境准备 1.鸿蒙NDK 下载安装方式可以参考上篇文章&#xff0c…...

滚雪球学Redis[6.3讲]:Redis分布式锁的实战指南:从基础到Redlock算法

全文目录&#xff1a; &#x1f389;前言&#x1f6a6;Redis分布式锁的概念与应用场景&#x1f343;1.1 什么是分布式锁&#xff1f;&#x1f342;1.2 应用场景 ⚙️使用Redis实现分布式锁&#x1f33c;2.1 基本思路&#x1f33b;2.2 示例代码&#x1f940;2.3 代码解析 &#…...

springboot二手汽车交易平台-计算机毕业设计源码82053

目录 1 绪论 1.1研究背景 1.2研究意义 1.3国内外研究现状 2 二手汽车交易平台系统分析 2.1 可行性分析 2.2 系统流程分析 2.3 功能需求分析 2.4 性能需求分析 3 二手汽车交易平台概要设计 3.1 系统体系结构设计 3.2总体功设计 3.3子模块设计设计 3.4 数据库设计 …...

typescript 中的类型推断

在 TypeScript 中&#xff0c;类型推断&#xff08;Type Inference&#xff09;是一种编译器自动确定变量或表达式类型的能力。这大大减少了需要显式声明类型的代码量&#xff0c;使得代码更加简洁和易读。TypeScript 的类型推断机制非常强大&#xff0c;可以在很多情况下自动推…...

linux 隐藏文件

在Linux中&#xff0c;隐藏文件以点&#xff08;.&#xff09;开头的文件或文件夹被认为是隐藏文件。隐藏文件通常用于存储系统配置文件或敏感文件。 以下是几种不同的方法来隐藏文件或文件夹&#xff1a; 方法1&#xff1a;在文件或文件夹名字前面加上点&#xff08;.&#…...

【网络协议栈】Tcp协议(上)结构的解析 和 Tcp中的滑动窗口(32位确认序号、32位序号、4位首部长度、6位标记位、16为窗口大小、16位紧急指针)

绪论​ “没有那么多天赋异禀&#xff0c;优秀的人总是努力翻山越岭。”本章主要讲到了再五层网络协议从上到下的第二层传输层中使用非常广泛的Tcp协议他的协议字段结构&#xff0c;通过这些字段去认识其Tcp协议运行的原理底层逻辑和基础。后面将会再写一篇Tcp到底是通过什么调…...

手表玻璃盖板视觉贴合

在手表生产过程中&#xff0c;贴合加工是一个至关重要的环节&#xff0c;它涉及将手表的盖板与LCM模组或各种功能片进行精准贴合。这一过程不仅要求高度的精度&#xff0c;还追求效率与稳定性&#xff0c;以满足现代可穿戴设备日益增长的市场需求。然而&#xff0c;当前行业在这…...

电信和互联网行业数据安全评估师CCRC-DSA人才强基计划

“电信和互联网行业数据安全人才强基计划”&#xff08;以下简称“强基计划”&#xff09;自 2022 年 4 月启动伊始&#xff0c;始终秉持以人才需求为导向&#xff0c;以体系化能力建设为重点&#xff0c;扎实铸就数据安全人才培养品牌&#xff0c;力促行业数据安全人才培养工作…...

华为云AI开发平台ModelArts

华为云ModelArts&#xff1a;重塑AI开发流程的“智能引擎”与“创新加速器”&#xff01; 在人工智能浪潮席卷全球的2025年&#xff0c;企业拥抱AI的意愿空前高涨&#xff0c;但技术门槛高、流程复杂、资源投入巨大的现实&#xff0c;却让许多创新构想止步于实验室。数据科学家…...

多模态2025:技术路线“神仙打架”,视频生成冲上云霄

文&#xff5c;魏琳华 编&#xff5c;王一粟 一场大会&#xff0c;聚集了中国多模态大模型的“半壁江山”。 智源大会2025为期两天的论坛中&#xff0c;汇集了学界、创业公司和大厂等三方的热门选手&#xff0c;关于多模态的集中讨论达到了前所未有的热度。其中&#xff0c;…...

Ubuntu系统下交叉编译openssl

一、参考资料 OpenSSL&&libcurl库的交叉编译 - hesetone - 博客园 二、准备工作 1. 编译环境 宿主机&#xff1a;Ubuntu 20.04.6 LTSHost&#xff1a;ARM32位交叉编译器&#xff1a;arm-linux-gnueabihf-gcc-11.1.0 2. 设置交叉编译工具链 在交叉编译之前&#x…...

Flask RESTful 示例

目录 1. 环境准备2. 安装依赖3. 修改main.py4. 运行应用5. API使用示例获取所有任务获取单个任务创建新任务更新任务删除任务 中文乱码问题&#xff1a; 下面创建一个简单的Flask RESTful API示例。首先&#xff0c;我们需要创建环境&#xff0c;安装必要的依赖&#xff0c;然后…...

【kafka】Golang实现分布式Masscan任务调度系统

要求&#xff1a; 输出两个程序&#xff0c;一个命令行程序&#xff08;命令行参数用flag&#xff09;和一个服务端程序。 命令行程序支持通过命令行参数配置下发IP或IP段、端口、扫描带宽&#xff0c;然后将消息推送到kafka里面。 服务端程序&#xff1a; 从kafka消费者接收…...

生成 Git SSH 证书

&#x1f511; 1. ​​生成 SSH 密钥对​​ 在终端&#xff08;Windows 使用 Git Bash&#xff0c;Mac/Linux 使用 Terminal&#xff09;执行命令&#xff1a; ssh-keygen -t rsa -b 4096 -C "your_emailexample.com" ​​参数说明​​&#xff1a; -t rsa&#x…...

自然语言处理——循环神经网络

自然语言处理——循环神经网络 循环神经网络应用到基于机器学习的自然语言处理任务序列到类别同步的序列到序列模式异步的序列到序列模式 参数学习和长程依赖问题基于门控的循环神经网络门控循环单元&#xff08;GRU&#xff09;长短期记忆神经网络&#xff08;LSTM&#xff09…...

vue3+vite项目中使用.env文件环境变量方法

vue3vite项目中使用.env文件环境变量方法 .env文件作用命名规则常用的配置项示例使用方法注意事项在vite.config.js文件中读取环境变量方法 .env文件作用 .env 文件用于定义环境变量&#xff0c;这些变量可以在项目中通过 import.meta.env 进行访问。Vite 会自动加载这些环境变…...

Linux --进程控制

本文从以下五个方面来初步认识进程控制&#xff1a; 目录 进程创建 进程终止 进程等待 进程替换 模拟实现一个微型shell 进程创建 在Linux系统中我们可以在一个进程使用系统调用fork()来创建子进程&#xff0c;创建出来的进程就是子进程&#xff0c;原来的进程为父进程。…...

HarmonyOS运动开发:如何用mpchart绘制运动配速图表

##鸿蒙核心技术##运动开发##Sensor Service Kit&#xff08;传感器服务&#xff09;# 前言 在运动类应用中&#xff0c;运动数据的可视化是提升用户体验的重要环节。通过直观的图表展示运动过程中的关键数据&#xff0c;如配速、距离、卡路里消耗等&#xff0c;用户可以更清晰…...