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

聊聊Spring AI的MilvusVectorStore

本文主要研究一下Spring AI的MilvusVectorStore

示例

pom.xml

		<dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-starter-vector-store-milvus</artifactId></dependency>

配置

spring:ai:vectorstore:milvus:initialize-schema: truedatabaseName: "default"collectionName: "test_collection1"embeddingDimension: 1024indexType: IVF_FLATmetricType: COSINEclient:host: "localhost"port: 19530

代码

    @Testpublic void testAddAndSearch() {List <Document> documents = List.of(new Document("Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!", Map.of("meta1", "meta1")),new Document("The World is Big and Salvation Lurks Around the Corner"),new Document("You walk forward facing the past and you turn back toward the future.", Map.of("meta2", "meta2")));// Add the documents to Milvus Vector StorevectorStore.add(documents);// Retrieve documents similar to a queryList<Document> results = this.vectorStore.similaritySearch(SearchRequest.builder().query("Spring").topK(5).build());log.info("results:{}", JSON.toJSONString(results));}

输出如下:

results:[{"contentFormatter":{"excludedEmbedMetadataKeys":[],"excludedInferenceMetadataKeys":[],"metadataSeparator":"\n","metadataTemplate":"{key}: {value}","textTemplate":"{metadata_string}\n\n{content}"},"formattedContent":"distance: 0.43509113788604736\nmeta1: meta1\n\nSpring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!","id":"d1c92394-77c8-4c67-9817-0980ad31479d","metadata":{"distance":0.43509113788604736,"meta1":"meta1"},"score":0.5649088621139526,"text":"Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!! Spring AI rocks!!"},{"contentFormatter":{"$ref":"$[0].contentFormatter"},"formattedContent":"distance: 0.5709311962127686\n\nThe World is Big and Salvation Lurks Around the Corner","id":"65d7ddb3-a735-4dad-9da0-cbba5665b149","metadata":{"distance":0.5709311962127686},"score":0.42906883358955383,"text":"The World is Big and Salvation Lurks Around the Corner"},{"contentFormatter":{"$ref":"$[0].contentFormatter"},"formattedContent":"distance: 0.5936022996902466\nmeta2: meta2\n\nYou walk forward facing the past and you turn back toward the future.","id":"26050d78-3396-4b61-97ea-111249f6d037","metadata":{"distance":0.5936022996902466,"meta2":"meta2"},"score":0.40639767050743103,"text":"You walk forward facing the past and you turn back toward the future."}]

源码

MilvusVectorStoreAutoConfiguration

org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java

@AutoConfiguration
@ConditionalOnClass({ MilvusVectorStore.class, EmbeddingModel.class })
@EnableConfigurationProperties({ MilvusServiceClientProperties.class, MilvusVectorStoreProperties.class })
@ConditionalOnProperty(name = SpringAIVectorStoreTypes.TYPE, havingValue = SpringAIVectorStoreTypes.MILVUS,matchIfMissing = true)
public class MilvusVectorStoreAutoConfiguration {@Bean@ConditionalOnMissingBean(MilvusServiceClientConnectionDetails.class)PropertiesMilvusServiceClientConnectionDetails milvusServiceClientConnectionDetails(MilvusServiceClientProperties properties) {return new PropertiesMilvusServiceClientConnectionDetails(properties);}@Bean@ConditionalOnMissingBean(BatchingStrategy.class)BatchingStrategy milvusBatchingStrategy() {return new TokenCountBatchingStrategy();}@Bean@ConditionalOnMissingBeanpublic MilvusVectorStore vectorStore(MilvusServiceClient milvusClient, EmbeddingModel embeddingModel,MilvusVectorStoreProperties properties, BatchingStrategy batchingStrategy,ObjectProvider<ObservationRegistry> observationRegistry,ObjectProvider<VectorStoreObservationConvention> customObservationConvention) {return MilvusVectorStore.builder(milvusClient, embeddingModel).initializeSchema(properties.isInitializeSchema()).databaseName(properties.getDatabaseName()).collectionName(properties.getCollectionName()).embeddingDimension(properties.getEmbeddingDimension()).indexType(IndexType.valueOf(properties.getIndexType().name())).metricType(MetricType.valueOf(properties.getMetricType().name())).indexParameters(properties.getIndexParameters()).iDFieldName(properties.getIdFieldName()).autoId(properties.isAutoId()).contentFieldName(properties.getContentFieldName()).metadataFieldName(properties.getMetadataFieldName()).embeddingFieldName(properties.getEmbeddingFieldName()).batchingStrategy(batchingStrategy).observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP)).customObservationConvention(customObservationConvention.getIfAvailable(() -> null)).build();}@Bean@ConditionalOnMissingBeanpublic MilvusServiceClient milvusClient(MilvusVectorStoreProperties serverProperties,MilvusServiceClientProperties clientProperties, MilvusServiceClientConnectionDetails connectionDetails) {var builder = ConnectParam.newBuilder().withHost(connectionDetails.getHost()).withPort(connectionDetails.getPort()).withDatabaseName(serverProperties.getDatabaseName()).withConnectTimeout(clientProperties.getConnectTimeoutMs(), TimeUnit.MILLISECONDS).withKeepAliveTime(clientProperties.getKeepAliveTimeMs(), TimeUnit.MILLISECONDS).withKeepAliveTimeout(clientProperties.getKeepAliveTimeoutMs(), TimeUnit.MILLISECONDS).withRpcDeadline(clientProperties.getRpcDeadlineMs(), TimeUnit.MILLISECONDS).withSecure(clientProperties.isSecure()).withIdleTimeout(clientProperties.getIdleTimeoutMs(), TimeUnit.MILLISECONDS).withAuthorization(clientProperties.getUsername(), clientProperties.getPassword());if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getUri())) {builder.withUri(clientProperties.getUri());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getToken())) {builder.withToken(clientProperties.getToken());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientKeyPath())) {builder.withClientKeyPath(clientProperties.getClientKeyPath());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getClientPemPath())) {builder.withClientPemPath(clientProperties.getClientPemPath());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getCaPemPath())) {builder.withCaPemPath(clientProperties.getCaPemPath());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerPemPath())) {builder.withServerPemPath(clientProperties.getServerPemPath());}if (clientProperties.isSecure() && StringUtils.hasText(clientProperties.getServerName())) {builder.withServerName(clientProperties.getServerName());}return new MilvusServiceClient(builder.build());}static class PropertiesMilvusServiceClientConnectionDetails implements MilvusServiceClientConnectionDetails {private final MilvusServiceClientProperties properties;PropertiesMilvusServiceClientConnectionDetails(MilvusServiceClientProperties properties) {this.properties = properties;}@Overridepublic String getHost() {return this.properties.getHost();}@Overridepublic int getPort() {return this.properties.getPort();}}}

MilvusVectorStoreAutoConfiguration在spring.ai.vectorstore.typemilvus会启用(matchIfMissing=true),它根据MilvusServiceClientProperties创建PropertiesMilvusServiceClientConnectionDetails,创建TokenCountBatchingStrategy、MilvusServiceClient,最后根据MilvusVectorStoreProperties创建MilvusVectorStore

MilvusServiceClientProperties

org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusServiceClientProperties.java

@ConfigurationProperties(MilvusServiceClientProperties.CONFIG_PREFIX)
public class MilvusServiceClientProperties {public static final String CONFIG_PREFIX = "spring.ai.vectorstore.milvus.client";/*** Secure the authorization for this connection, set to True to enable TLS.*/protected boolean secure = false;/*** Milvus host name/address.*/private String host = "localhost";/*** Milvus the connection port. Value must be greater than zero and less than 65536.*/private int port = 19530;/*** The uri of Milvus instance*/private String uri;/*** Token serving as the key for identification and authentication purposes.*/private String token;/*** Connection timeout value of client channel. The timeout value must be greater than* zero.*/private long connectTimeoutMs = 10000;/*** Keep-alive time value of client channel. The keep-alive value must be greater than* zero.*/private long keepAliveTimeMs = 55000;/*** Enables the keep-alive function for client channel.*/// private boolean keepAliveWithoutCalls = false;/*** The keep-alive timeout value of client channel. The timeout value must be greater* than zero.*/private long keepAliveTimeoutMs = 20000;/*** Deadline for how long you are willing to wait for a reply from the server. With a* deadline setting, the client will wait when encounter fast RPC fail caused by* network fluctuations. The deadline value must be larger than or equal to zero.* Default value is 0, deadline is disabled.*/private long rpcDeadlineMs = 0; // Disabling deadline/*** The client.key path for tls two-way authentication, only takes effect when "secure"* is True.*/private String clientKeyPath;/*** The client.pem path for tls two-way authentication, only takes effect when "secure"* is True.*/private String clientPemPath;/*** The ca.pem path for tls two-way authentication, only takes effect when "secure" is* True.*/private String caPemPath;/*** server.pem path for tls one-way authentication, only takes effect when "secure" is* True.*/private String serverPemPath;/*** Sets the target name override for SSL host name checking, only takes effect when* "secure" is True. Note: this value is passed to grpc.ssl_target_name_override*/private String serverName;/*** Idle timeout value of client channel. The timeout value must be larger than zero.*/private long idleTimeoutMs = TimeUnit.MILLISECONDS.convert(24, TimeUnit.HOURS);/*** The username and password for this connection.*/private String username = "root";/*** The password for this connection.*/private String password = "milvus";//......
}	

MilvusServiceClientProperties提供了spring.ai.vectorstore.milvus.client的配置,可以设置host、port、connectTimeoutMs、username、password等

PropertiesMilvusServiceClientConnectionDetails

org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreAutoConfiguration.java

	static class PropertiesMilvusServiceClientConnectionDetails implements MilvusServiceClientConnectionDetails {private final MilvusServiceClientProperties properties;PropertiesMilvusServiceClientConnectionDetails(MilvusServiceClientProperties properties) {this.properties = properties;}@Overridepublic String getHost() {return this.properties.getHost();}@Overridepublic int getPort() {return this.properties.getPort();}}

PropertiesMilvusServiceClientConnectionDetails实现了MilvusServiceClientConnectionDetails接口,适配了getHost、getPort方法

MilvusVectorStoreProperties

org/springframework/ai/vectorstore/milvus/autoconfigure/MilvusVectorStoreProperties.java

@ConfigurationProperties(MilvusVectorStoreProperties.CONFIG_PREFIX)
public class MilvusVectorStoreProperties extends CommonVectorStoreProperties {public static final String CONFIG_PREFIX = "spring.ai.vectorstore.milvus";/*** The name of the Milvus database to connect to.*/private String databaseName = MilvusVectorStore.DEFAULT_DATABASE_NAME;/*** Milvus collection name to store the vectors.*/private String collectionName = MilvusVectorStore.DEFAULT_COLLECTION_NAME;/*** The dimension of the vectors to be stored in the Milvus collection.*/private int embeddingDimension = MilvusVectorStore.OPENAI_EMBEDDING_DIMENSION_SIZE;/*** The type of the index to be created for the Milvus collection.*/private MilvusIndexType indexType = MilvusIndexType.IVF_FLAT;/*** The metric type to be used for the Milvus collection.*/private MilvusMetricType metricType = MilvusMetricType.COSINE;/*** The index parameters to be used for the Milvus collection.*/private String indexParameters = "{\"nlist\":1024}";/*** The ID field name for the collection.*/private String idFieldName = MilvusVectorStore.DOC_ID_FIELD_NAME;/*** Boolean flag to indicate if the auto-id is used.*/private boolean isAutoId = false;/*** The content field name for the collection.*/private String contentFieldName = MilvusVectorStore.CONTENT_FIELD_NAME;/*** The metadata field name for the collection.*/private String metadataFieldName = MilvusVectorStore.METADATA_FIELD_NAME;/*** The embedding field name for the collection.*/private String embeddingFieldName = MilvusVectorStore.EMBEDDING_FIELD_NAME;//......public enum MilvusMetricType {/*** Invalid metric type*/INVALID,/*** Euclidean distance*/L2,/*** Inner product*/IP,/*** Cosine distance*/COSINE,/*** Hamming distance*/HAMMING,/*** Jaccard distance*/JACCARD}public enum MilvusIndexType {INVALID, FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, HNSW, DISKANN, AUTOINDEX, SCANN, GPU_IVF_FLAT, GPU_IVF_PQ, BIN_FLAT,BIN_IVF_FLAT, TRIE, STL_SORT}}	

MilvusVectorStoreProperties提供了spring.ai.vectorstore.milvus的配置,主要是配置databaseName、collectionName、embeddingDimension(默认1536)、indexType(默认IVF_FLAT)、metricType(默认COSINE)

CommonVectorStoreProperties

org/springframework/ai/vectorstore/properties/CommonVectorStoreProperties.java

public class CommonVectorStoreProperties {/*** Vector stores do not initialize schema by default on application startup. The* applications explicitly need to opt-in for initializing the schema on startup. The* recommended way to initialize the schema on startup is to set the initialize-schema* property on the vector store. See {@link #setInitializeSchema(boolean)}.*/private boolean initializeSchema = false;public boolean isInitializeSchema() {return this.initializeSchema;}public void setInitializeSchema(boolean initializeSchema) {this.initializeSchema = initializeSchema;}}

CommonVectorStoreProperties定义了initializeSchema属性,代表说是否需要在启动的时候初始化schema

小结

Spring AI提供了spring-ai-starter-vector-store-milvus用于自动装配MilvusVectorStore。要注意的是embeddingDimension默认是1536,如果出现io.milvus.exception.ParamException: Incorrect dimension for field 'embedding': the no.0 vector's dimension: 1024 is not equal to field's dimension: 1536,那么需要重建schema,把embeddingDimension设置为1024。

doc

  • milvus

相关文章:

聊聊Spring AI的MilvusVectorStore

序 本文主要研究一下Spring AI的MilvusVectorStore 示例 pom.xml <dependency><groupId>org.springframework.ai</groupId><artifactId>spring-ai-starter-vector-store-milvus</artifactId></dependency>配置 spring:ai:vectorstore:…...

前后端通信指南

HTTP 协议与 RESTful APIWebSocket 与实时通信一、前后端通信概述 前后端通信是现代 Web 开发的核心环节,前端(浏览器或移动端)需要向后端请求数据,并根据返回的数据渲染界面。常见的通信方式包括 HTTP 请求、RESTful API、WebSocket、GraphQL 等。 常见前后端通信方式 通…...

[特殊字符] 驱动开发硬核特训 · Day 2

主题&#xff1a;深入掌握 UART 与 SPI 驱动开发原理、架构与调试技术 本期围绕实际项目中应用最广泛的两类外设通信接口 —— UART&#xff08;串口&#xff09;与 SPI&#xff08;串行外设接口&#xff09;&#xff0c;通过结构化知识点梳理&#xff0c;结合实际驱动开发流程…...

B树和B+树的区别(B Tree B+ Tree)

前言 B树和B树是数据库中常用的索引结构&#xff0c;它们的核心区别主要体现在数据存储方式、节点结构和适用场景上。 关键区别详解 数据存储方式&#xff1a; B树&#xff1a;所有节点均存储键值&#xff08;key-data&#xff09;对&#xff0c;数据可能分布在树的任意层级。…...

32--当网络接口变成“夜店门口“:802.1X协议深度解码(理论纯享版本)

当网络接口变成"夜店门口"&#xff1a;802.1X协议深度解码 引言&#xff1a;网口的"保安队长"上岗记 如果把企业网络比作高端会所&#xff0c;那么802.1X协议就是门口那个拿着金属探测器的黑超保安。它会对着每个想进场的设备说&#xff1a;“请出示您的会…...

【LLM】使用MySQL MCP Server让大模型轻松操作本地数据库

随着MCP协议&#xff08;Model Context Protocol&#xff09;的出现&#xff0c;使得 LLM 应用与外部数据源和工具之间的无缝集成成为可能&#xff0c;本章就介绍如何通过MCP Server让LLM能够直接与本地的MySQL数据库进行交互&#xff0c;例如新增、修改、删除数据&#xff0c;…...

MOM成功实施分享(八)汽车活塞生产制造MOM建设方案(第一部分)

在制造业数字化转型的浪潮中&#xff0c;方案对活塞积极探索&#xff0c;通过实施一系列数字化举措&#xff0c;在生产管理、供应链协同、质量控制等多个方面取得显著成效&#xff0c;为行业提供了优秀范例。 1.转型背景与目标&#xff1a;活塞在数字化转型前面临诸多挑战&…...

程序化广告行业(59/89):广告验证与反作弊实战技巧

程序化广告行业&#xff08;59/89&#xff09;&#xff1a;广告验证与反作弊实战技巧 大家好&#xff01;在程序化广告领域&#xff0c;想要做好投放&#xff0c;除了了解基本的架构和原理&#xff0c;还得掌握一些关键的技能&#xff0c;比如广告验证和反作弊。今天就和大家一…...

市场趋势分析与交易策略调整

市场趋势分析与交易策略调整 在市场交易中&#xff0c;趋势的判断与策略的调整至关重要。不同市场环境下&#xff0c;交易者需要灵活运用技术分析和资金管理手段&#xff0c;以提升交易的稳定性。本文将探讨市场趋势的识别方法&#xff0c;以及如何在不同市场环境中调整交易策略…...

安卓离线畅玩的多款棋类单机游戏推荐

软件介绍 在手游盛行的当下&#xff0c;不少玩家在网游激战之余&#xff0c;渴望一份单机游戏带来的宁静与专注。今天要为大家介绍的&#xff0c;便是一款能满足此类需求的安卓软件 —— 棋类大师。 它巧妙地将象棋、围棋、五子棋三种经典棋类游戏集成于一身&#xff0c;且具…...

论文阅读Diffusion Autoencoders: Toward a Meaningful and Decodable Representation

原文框架图&#xff1a; 官方代码&#xff1a; https://github.com/phizaz/diffae/blob/master/interpolate.ipynb 主要想记录一下模型的推理过程 &#xff1a; %load_ext autoreload %autoreload 2 from templates import * device cuda:1 conf ffhq256_autoenc() # pri…...

医疗信息系统的主要痛点分析

医疗信息系统的主要痛点分析 1. 数据治理问题 数据标准不统一 各医院采用不同的数据格式和编码标准诊断术语、药品编码等缺乏统一规范检验检查结果的参考值范围不一致 数据质量参差不齐 数据录入不规范&#xff0c;存在大量错误和缺失历史数据清洗难度大数据更新不及时 数据安…...

Pycharm v2024.3.4 Windows Python开发工具

Pycharm v2024.3.4 Windows Python开发工具 文章目录 Pycharm v2024.3.4 Windows Python开发工具一、介绍二、效果三、下载 一、介绍 JetBrains PyCharm 是一款Python集成开发环境&#xff08;IDE&#xff09;&#xff0c;被广泛用于Python开发 二、效果 三、下载 百度网盘: …...

YOLOv12 从预训练迈向自主训练,第一步数据准备

视频讲解&#xff1a; YOLOv12 从预训练迈向自主训练&#xff0c;第一步数据准备 前面复现过yolov12&#xff0c;使用pre-trained的模型进行过测试&#xff0c;今天来讲下如何训练自己的模型&#xff0c;第一步先准备数据和训练格式 https://gitcode.com/open-source-toolkit/…...

Java 线程池全面解析

Java 线程池全面解析 一、线程池种类及优缺点 1. 常见线程池类型(通过Executors创建) 线程池类型创建方式特点适用场景缺点FixedThreadPoolExecutors.newFixedThreadPool(n)固定线程数,无界队列负载较重的服务器可能堆积大量任务导致OOMCachedThreadPoolExecutors.newCach…...

第七章 Python基础进阶-异常、模块与包(其五)

目录 一.异常 二.异常的捕获方法 1.捕获常规异常 2.捕获指定异常 3.捕获多个异常 4.异常else 5.异常的finally 三.异常的传递 四.Python模块 1.import导入模块 2.from导入模块 3.from模块名 import* 4.as定义别名 5.自定义模块 &#xff08;1&#xff09;测试模块…...

vulkanscenegraph显示倾斜模型(5.6)-vsg::RenderGraph的创建

前言 上一章深入分析了vsg::CommandGraph的创建过程及其通过子场景遍历实现Vulkan命令录制的机制。本章将在该基础上&#xff0c;进一步探讨Vulkan命令录制中的核心封装——vsg::RenderGraph。作为渲染流程的关键组件&#xff0c;RenderGraph封装了vkCmdBeginRenderPass和vkCmd…...

DelayQueue vs ScheduledThreadPool:Java定时任务的双雄争霸

定时任务管理的两种武林绝学 想象你需要管理一个跨时区的视频会议系统&#xff1a; DelayQueue 像一位严格的计时员&#xff0c;把所有会议请求按时间排序&#xff0c;到点才放行ScheduledThreadPool 像一位智能秘书&#xff0c;能主动安排、取消和调整会议时间 它们都能处理…...

Qt添加资源文件

目录 1.创建一个新项目 1.1菜单栏 添加菜单项 1.2工具栏 1.3铆接部件 1.4中心部件 1.5最终界面 2.资源文件 2.1将图片文件拷贝到项目位置下 2.2添加新文件 2.3rec.qrc文件 2.4添加前缀&#xff0c;添加文件 2.5使用 1.创建一个新项目 利用界面文件完成一个有菜单…...

U-Net: Convolutional Networks for BiomedicalImage Segmentation

Abstract 人们普遍认为&#xff0c;深度网络的成功训练需要成千上万的标注训练样本。在本文中&#xff0c;我们提出了一种网络和训练策略&#xff0c;该策略强烈依赖于数据增强&#xff0c;以更有效地利用现有的标注样本。该架构包括一个用于捕获上下文的收缩路径和一个用于实…...

28--当路由器开始“宫斗“:设备控制面安全配置全解

当路由器开始"宫斗"&#xff1a;设备控制面安全配置全解 引言&#xff1a;路由器的"大脑保卫战" 如果把网络世界比作一座繁忙的城市&#xff0c;那么路由器就是路口执勤的交通警察。而控制面&#xff08;Control Plane&#xff09;就是警察的大脑&#xf…...

NHANES指标推荐:DI-GM

文章题目&#xff1a;The relationship between dietary index for gut microbiota and diabetes DOI&#xff1a;10.1038/s41598-025-90854-y 中文标题&#xff1a;肠道菌群膳食指数与糖尿病的关系 发表杂志&#xff1a;Sci Rep 影响因子&#xff1a;1区&#xff0c;IF3.8 发表…...

仓库规划 第32次CCF-CSP计算机软件能力认证

没什么说的暴力枚举 n*n*m 的时间复杂度 题目说选序号小的作为父亲 直接编号前往后输出 遇到合适的就break #include<bits/stdc.h> using namespace std; int n, m; int main() {cin >> n >> m;//n:仓库个数 m:位置编码的维数vector<vector<int>…...

leetcode-代码随想录-哈希表-哈希理论基础

哈希表理论基础 哈希表&#xff1a;或者称为散列表&#xff0c;是根据关键码的值而直接进行访问的数据结构。 哈希法&#xff1a;用于快速判断一个元素是否出现在集合里 哈希函数是⼀种映射关系&#xff0c;根据关键词key&#xff0c;经过⼀定函数关系 f 得到元素的位置。 存…...

《科学》期刊发布新成果:量子计算迎来原子 - 光腔集成新时代

《Error-detected quantum operations with neutral atoms mediated by an optical cavity》 -《Science》 2025.3.21 摘要 光镊&#xff08;optical tweezers&#xff09;束缚的可编程原子阵列已成为量子信息处理&#xff08;quantum information processing&#xff09;和量…...

Spring Boot 与 TDengine 的深度集成实践(一)

引言 在当今数字化时代&#xff0c;数据处理与存储对于各类应用的重要性不言而喻。Spring Boot 作为一款流行的 Java 开发框架&#xff0c;以其快速开发、约定大于配置、内嵌容器等特性&#xff0c;大大提升了 Java 企业级应用的开发效率&#xff0c;降低了开发门槛&#xff0…...

SpringBoot + Netty + Vue + WebSocket实现在线聊天

最近想学学WebSocket做一个实时通讯的练手项目 主要用到的技术栈是WebSocket Netty Vue Pinia MySQL SpringBoot&#xff0c;实现一个持久化数据&#xff0c;单一群聊&#xff0c;支持多用户的聊天界面 下面是实现的过程 后端 SpringBoot启动的时候会占用一个端口&#xff…...

数据结构实验2.3:Josephus问题求解

文章目录 一&#xff0c;问题描述二&#xff0c;基本要求三&#xff0c;算法设计&#xff08;1&#xff09;存储结构设计&#xff08;2&#xff09;算法设计 四&#xff0c;示例代码五&#xff0c;运行效果 一&#xff0c;问题描述 在现实生活以及计算机科学的一些场景中&…...

Ruby语言的代码重构

Ruby语言的代码重构&#xff1a;探索清晰、可维护与高效的代码 引言 在软件开发的过程中&#xff0c;代码的质量直接影响到项目的可维护性、扩展性和整体性能。随着时间的推移&#xff0c;系统的需求变化&#xff0c;代码可能会变得混乱和难以理解&#xff0c;因此&#xff0…...

CAN/FD CAN总线配置 最新详解 包含理论+实战(附带源码)

看前须知&#xff1a;本篇文章不会说太多理论性的内容&#xff08;重点在理论结合实践&#xff09;&#xff0c;顾及实操&#xff0c;应用&#xff0c;一切理论内容支撑都是为了后续实际操作进行铺垫&#xff0c;重点在于读者可以看完文章应用。&#xff08;也为节约读者时间&a…...

杰文字悖论:效率提升的副作用

最近&#xff0c;Deepseek的火爆让我们开始反思一个有趣的现象&#xff1a;杰文斯悖论。这是1856年&#xff0c;经济学家杰文斯提出来的一个有趣的现象&#xff1a;当技术效率提高时&#xff0c;资源的使用量反而会增加&#xff0c;而不是减少。听起来可能有点不可思议。杰文斯…...

AcWing 6118. 蛋糕游戏

贪心 为了方便描述&#xff0c;下面将贝茜和埃尔茜分别称为a、b。 已知蛋糕的数量为偶数个&#xff0c;b每次只能吃左右边界上的蛋糕&#xff0c;a每次操作将两个蛋糕变成一个&#xff0c;发现都会使蛋糕的数量减一&#xff0c;且a先操作将蛋糕数量从偶数变成奇数&#xff0c…...

【前端】【Nuxt3】Nuxt 3 开发中因生命周期理解不足导致的常见错误分类及其解决方案

以下是 Nuxt 3 开发中因生命周期理解不足导致的常见错误分类及其解决方案&#xff0c;以结构化形式呈现&#xff1a; 一、数据获取与异步处理 错误 1&#xff1a;错误使用客户端钩子获取数据 问题&#xff1a;在 onMounted 中获取数据&#xff0c;导致 SSR 失效。示例&#x…...

【kubernetes】BusyBox

目录 1. 说明2. 在 Kubernetes 中的角色2.1 轻量级调试工具2.2 临时容器2.3 网络测试2.4 文件系统检查 3. 为什么选择 BusyBox&#xff1f;4. 常见用法5. 注意事项 1. 说明 1.BusyBox 是一个轻量级、开源的 Linux 工具集&#xff0c;将多种常见的 Unix 工具&#xff08;如 ls、…...

Leetcode——239. 滑动窗口最大值

题解一 思路 第一次做困难的题&#xff0c;确实把我既困住了又难住了&#xff0c;确实自己一点都想不出来。 这个思路&#xff0c;差不多就是&#xff0c;自己定义一个单调队列。 添加的时候&#xff0c;判断是否比队列最后的元素大&#xff0c;如果比它大&#xff0c;就把…...

kubernetes configMap 存储

1.模型 首先会在每一个节点上安装一个叫 agent 端 agent 端要做的作用就是监听当前的目标配置中心的配置选项是否发送更新动作 如果有的话 我的agent 端的话要从远程的配置中心 去下载最新的配置文件 替换我当前的 再去触发nginx实现重载 当然对于后期的运维工程师 如果想去发…...

架构思维:查询分离 - 表数据量大查询缓慢的优化方案

文章目录 Pre引言案例何谓查询分离&#xff1f;何种场景下使用查询分离&#xff1f;查询分离实现思路1. 如何触发查询分离&#xff1f;方式一&#xff1a; 修改业务代码&#xff1a;在写入常规数据后&#xff0c;同步建立查询数据。方式二&#xff1a;修改业务代码&#xff1a;…...

A2DP(Advanced Audio Distribution Profile)是蓝牙协议栈中用于音频传输的一个标准化协议

A2DP&#xff08;Advanced Audio Distribution Profile&#xff09;是蓝牙协议栈中用于音频传输的一个标准化协议&#xff0c;主要用于高质量音频流的无线传输。以下是A2DP协议的详细信息&#xff1a; 定义 A2DP协议允许音源设备&#xff08;Source&#xff0c;简称SRC&#…...

Redisson使用详解

一、Redisson 核心特性与适用场景 Redisson 是基于 Redis 的 Java 客户端&#xff0c;提供分布式对象、锁、集合和服务&#xff0c;简化分布式系统开发。 典型应用场景&#xff1a; 分布式锁&#xff1a;防止重复扣款、超卖控制&#xff08;如秒杀库存&#xff09;。数据共享…...

GraalVM 24 正式发布阿里巴巴贡献重要特性 —— 支持 Java Agent 插桩

作者&#xff1a;林子熠、饶子昊 2025 年 3 月 18 日 Oracle 双箭齐发&#xff0c;正式发布了 JDK 24 和 GraalVM 24&#xff0c;带来了众多新特性。 JDK 24 在性能和安全性方面均有改进&#xff08;特性列表链接见下&#xff09;&#xff0c;其中较大的一处改动是在 JDK 中…...

游戏编程模式学习(编程质量提升之路)

文章目录 前言一、命令模式&#xff08;Command Pattern&#xff09;1.命令模式练习场景I.需求场景 2.解耦命令与执行者3.使用命令对玩家角色和AI的操作进行统一抽象4. 命令模式的撤销实现 二、享元模式1.应用场景2.目的3.实现方式 三、原型模式1.运用场景2.实现方式 四、状态模…...

计算机视觉五大技术——深度学习在图像处理中的应用

深度学习是利用“多层神经网络”实现人工智能的一种方式 计算机视觉&#xff1a;“对图像中的客观对象构建明确而有意义的描述”&#xff0c;识别图片中的含义进行处理 1.图像分类——“图里有狗” 判断整张图片属于哪个类别&#xff0c;判断图片是“猫”还是“狗” 思路&a…...

Mixed Content: The page at https://xxx was loaded over HTTPS

一、核心原因分析 Mixed Content 警告是由于 HTTPS 页面中引用了 HTTP 协议的资源(如脚本、图片、iframe 等),导致浏览器因安全策略阻止加载这些非加密内容。HTTP 资源可能被中间人攻击篡改,破坏 HTTPS 页面的整体安全性。 二、推荐解决方案 1. 强制资源升级为 HTTPS •…...

transforms-pytorch4

数据通常不会直接是机器学习算法可以使用的“最终格式”。我们使用转换&#xff08;transforms&#xff09;来对数据进行处理&#xff0c;使其适合训练。 所有的 TorchVision 数据集都提供了两个参数&#xff1a;transform 用于修改特征&#xff0c;target_transform 用于修改…...

Springboot----@Role注解的作用

Role(BeanDefinition.ROLE_INFRASTRUCTURE) 是 Spring 框架中的一个注解&#xff0c;用于显式标记 Bean 的角色&#xff0c;表明该 Bean 是 Spring 容器内部的基础设施组件&#xff08;如后置处理器、工具类等&#xff09;&#xff0c;而非用户直接使用的业务 Bean。其核心作用…...

SpringBoot项目报错: 缺少 Validation

目录 为什么需要Validation&#xff1f;如何使用Validation&#xff1f; 缺少validation&#xff1f;这不过是代码的一个小小问题&#xff0c;就像被风带走的一片叶子&#xff0c;轻轻一吹就能解决啦&#xff01; 在你的项目中&#xff0c;如果你发现自己需要进行数据验证&…...

MySQL vs MSSQL 对比

在企业数据库管理系统中&#xff0c;MySQL 和 Microsoft SQL Server&#xff08;MSSQL&#xff09;是最受欢迎的两大选择。MySQL 是一款开源的关系型数据库管理系统&#xff08;RDBMS&#xff09;&#xff0c;由 MySQL AB 开发&#xff0c;现归属于 Oracle 公司。而 MSSQL 是微…...

预测分析(四):面向预测分析的神经网络简介

文章目录 面向预测分析的神经网络简介神经网络模型1. 基本概念2. 前馈神经网络3. 常见激活函数4. 循环神经网络&#xff08;RNN&#xff09;5. 卷积神经网络&#xff08;CNN&#xff09; MPL结构工作原理激活函数训练方法 基于神经网络的回归——以钻石为例构建预测钻石价格的M…...

实战交易策略 篇十四:江南神鹰捕捉热点和熊市生存交易策略

文章目录 系列文章捕捉热点是股市最大的掘金术市场温度不低于50是热点产生的必要条件题材的大小和新颖程度决定热点的持续时间和涨幅炒作热点的3个阶段捕捉热点的方法与步骤操作实战案例熊市生存术“熊市最好的做法是离开股市”的说法是一句空话熊市盈利模式:不轻言底部,超跌…...

去中心化衍生品(以Synthetix为例)

去中心化衍生品&#xff08;以Synthetix为例&#xff09; 核心概念 合成资产&#xff08;Synths&#xff09;&#xff1a; 定义&#xff1a;链上追踪现实资产价值的代币化合约&#xff08;如sXAU追踪黄金&#xff0c;iBTC反向追踪比特币&#xff09;。 类型&#xff1a; 正…...