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

SpringBoot项目接入DeepSeek

        在这个demo当中,我使用的是JDK8+Spring Boot 2.6.x,下面直接给大家附上完整的代码。

一、项目结构

deepseek - demo/
├── src/
│   ├── main/
│   │   ├── java/
│   │   │   └── cn/
│   │   │       └── mzl/
│   │   │           └── deepseekdemo/
│   │   │               ├── config/
│   │   │               │   ├── DeepSeekConfig  # 配置相关类
│   │   │               │   └── RetryInterceptor  # 重试拦截器类
│   │   │               ├── controller/
│   │   │               │   └── ChatController  # REST接口类
│   │   │               ├── exception/
│   │   │               │   ├── ApiException  # 自定义异常类
│   │   │               │   └── GlobalExceptionHandler  # 全局异常处理类
│   │   │               ├── service/
│   │   │               │   ├── impl/
│   │   │               │   │   └── DeepSeekServiceImpl  # 服务实现类
│   │   │               │   └── DeepSeekService  # 核心服务接口
│   │   │               └── DeepseekDemoApplication  # 启动类
│   │   └── resources/
│   │       ├── static/
│   │       │   ├── css/
│   │       │   │   └── chat.css  # 聊天页面样式文件
│   │       │   ├── js/
│   │       │   │   └── chat.js  # 聊天功能相关脚本文件
│   │       │   └── index.html  # 页面文件
│   │       └── application.yml  # 配置文件
│   └── test/
└── target/

二、项目代码 (后端)

1.pom.xml 

<?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><groupId>cn.mzl</groupId><artifactId>deepseek-demo</artifactId><version>0.0.1-SNAPSHOT</version><name>deepseek-demo</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><spring-boot.version>2.6.13</spring-boot.version><okhttp.version>4.9.3</okhttp.version><lombok.version>1.18.34</lombok.version><snakeyaml.version>1.33</snakeyaml.version> <!-- 兼容JDK8的版本 --></properties><dependencies><!-- Spring Boot Starter --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>${spring-boot.version}</version></dependency><!-- 添加显式依赖 --><dependency><groupId>org.yaml</groupId><artifactId>snakeyaml</artifactId><version>${snakeyaml.version}</version></dependency><!-- HTTP Client --><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>${okhttp.version}</version></dependency><!-- Lombok --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version><scope>provided</scope></dependency><!-- 测试 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><version>${spring-boot.version}</version><scope>test</scope></dependency><!-- 接口文档 --><dependency><groupId>io.swagger.core.v3</groupId><artifactId>swagger-core</artifactId><version>2.2.15</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>RELEASE</version><scope>compile</scope></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>${spring-boot.version}</version><configuration><mainClass>cn.mzl.deepseekdemo.DeepseekDemoApplication</mainClass><skip>true</skip></configuration><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build></project>

2. application.yml

server:port: 8080deepseek:api:url: https://api.deepseek.com/v1/chat/completionskey: ${DEEPSEEK_API_KEY:填写自己的API_KEY} # 优先使用环境变量timeout: 30000 # 毫秒logging:level:root: INFOcom.example.deepseek: DEBUG

        API_KEY可以登录DeepSeek官网的API开放平台创建,具体如下图所示:

        在DeepSeek官网点击右上角的“API开放平台”,会出现如下页面:

        点击API Keys,接着再点击创建API Key,弹出如下窗口:

        该名称可以随便填写,然后点击创建即可。需要注意的是:API key 仅在创建时可见可复制。

3. DeepSeekConfig.java

@Data
@Configuration
@ConfigurationProperties(prefix = "deepseek.api")
public class DeepSeekConfig {private String url;private String key;private Integer timeout;@Beanpublic OkHttpClient okHttpClient() {return new OkHttpClient.Builder()//重试3次.addInterceptor(new RetryInterceptor(3)).connectTimeout(timeout, TimeUnit.MILLISECONDS).readTimeout(timeout, TimeUnit.MILLISECONDS).writeTimeout(timeout, TimeUnit.SECONDS).build();}/*** 验证API密钥有效性*/@PostConstructpublic void validateConfig() {if (StringUtils.isEmpty(key)) {throw new IllegalStateException("DeepSeek API密钥未配置");}if (!key.startsWith("sk-")) {throw new IllegalStateException("API密钥格式不正确");}}
}

4. RetryInterceptor.java

public class RetryInterceptor implements Interceptor {private int maxRetries;public RetryInterceptor(int maxRetries) {this.maxRetries = maxRetries;}@Overridepublic Response intercept(Chain chain) throws IOException {Request request = chain.request();Response response = null;IOException exception = null;for (int i = 0; i <= maxRetries; i++) {try {response = chain.proceed(request);if (response.isSuccessful()) {return response;}} catch (IOException e) {exception = e;}}if (exception != null){ throw exception;}return response;}
}

 5. DeepSeekService.java

public interface DeepSeekService {String chatCompletion(String prompt) throws ApiException;
}

6. DeepSeekServiceImpl.java

@Service
@Slf4j
public class DeepSeekServiceImpl implements DeepSeekService {private final OkHttpClient client;private final ObjectMapper objectMapper;private final DeepSeekConfig config;public DeepSeekServiceImpl(OkHttpClient client,DeepSeekConfig config) {this.client = client;this.objectMapper = new ObjectMapper();this.config = config;}@Overridepublic String chatCompletion(String prompt) throws ApiException {try {Request request = buildRequest(prompt);log.debug("Sending request to: {}", config.getUrl());log.debug("Request headers: {}", request.headers());Response response = client.newCall(request).execute();log.debug("Response code: {}", response.code());return processResponse(client.newCall(request).execute());} catch (IOException e) {log.error("API请求失败: {}", e.getMessage());throw new ApiException("DeepSeek服务调用失败", e);}}private Request buildRequest(String prompt) throws IOException {String jsonBody = objectMapper.createObjectNode().put("model", "deepseek-chat").set("messages", objectMapper.createArrayNode().add(objectMapper.createObjectNode().put("role", "user").put("content", prompt))).toString();return new Request.Builder().url(config.getUrl()).addHeader("Authorization", "Bearer " + config.getKey()).post(RequestBody.create(jsonBody, MediaType.get("application/json"))).build();}private String processResponse(Response response) throws IOException {if (!response.isSuccessful()) {throw new IOException("HTTP错误: " + response.code());}JsonNode rootNode = objectMapper.readTree(response.body().byteStream());return rootNode.path("choices").get(0).path("message").path("content").asText();}
}

7. ChatController.java

@RestController
@RequestMapping("/api/chat")
public class ChatController {private final DeepSeekService deepSeekService;public ChatController(DeepSeekService deepSeekService) {this.deepSeekService = deepSeekService;}@PostMappingpublic String chat(@RequestBody String prompt) {try {return deepSeekService.chatCompletion(prompt);} catch (ApiException e) {throw new RuntimeException("服务调用失败");}}
}

8. 全局异常处理(GlobalExceptionHandler.java  &  ApiException.java

GlobalExceptionHandler.java

@RestControllerAdvice
public class GlobalExceptionHandler {@ExceptionHandler(ApiException.class)public String handleApiException(ApiException e) {return "错误: " + e.getMessage();}@ExceptionHandler(Exception.class)public String handleGeneralException(Exception e) {return "系统错误: " + e.getMessage();}
}

ApiException.java

@Getter
public class ApiException extends Exception {private final int errorCode;public ApiException(String message) {super(message);this.errorCode = 500;}public ApiException(int errorCode, String message) {super(message);this.errorCode = errorCode;}public ApiException(String message, Throwable cause) {super(message, cause);this.errorCode = 500;}
}

9. DeepseekDemoApplication.java

@SpringBootApplication
public class DeepseekDemoApplication {public static void main(String[] args) {SpringApplication.run(DeepseekDemoApplication.class, args);}}

        后端部分的代码到这里就算是写完了,接下来再看写前端部分的代码,前端只实现了基础的对话及展示功能,后续可以自己根据需要进行修改和添加更多功能。

三、项目代码 (前端)

1. chat.css

/* 基础样式 */
body {margin: 0;background: #f0f2f5;font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}.chat-container {max-width: 800px;margin: 20px auto;background: white;border-radius: 10px;box-shadow: 0 2px 10px rgba(0,0,0,0.1);padding: 20px;
}/* 对话历史区域 */
.chat-history {height: 70vh;overflow-y: auto;padding: 10px;border-bottom: 1px solid #eee;
}/* 消息通用样式 */
.message {display: flex;gap: 15px;margin: 15px 0;animation: fadeIn 0.3s ease-in;
}.user-message {flex-direction: row-reverse;
}/* 头像 */
.avatar {width: 40px;height: 40px;border-radius: 50%;background: #e8e8e8;display: flex;align-items: center;justify-content: center;font-size: 20px;
}/* 消息内容 */
.content {max-width: 70%;padding: 12px 16px;border-radius: 15px;line-height: 1.6;
}.user-message .content {background: #1890ff;color: white;border-radius: 15px 15px 0 15px;
}.bot-message .content {background: #f5f5f5;color: #333;border-radius: 15px 15px 15px 0;
}/* 输入区域 */
.input-area {display: flex;gap: 10px;padding: 20px 10px 0;
}textarea {flex: 1;padding: 12px;border: 1px solid #ddd;border-radius: 8px;resize: none;font-size: 16px;min-height: 44px;
}button {padding: 0 20px;height: 44px;background: #1890ff;color: white;border: none;border-radius: 8px;cursor: pointer;transition: background 0.2s;
}button:hover {background: #096dd9;
}/* 加载动画 */
.loading {display: none;padding: 15px;text-align: center;
}.dot-flashing {position: relative;width: 10px;height: 10px;border-radius: 5px;background-color: #1890ff;animation: dotFlashing 1s infinite linear;
}@keyframes fadeIn {from { opacity: 0; transform: translateY(10px); }to { opacity: 1; transform: translateY(0); }
}@keyframes dotFlashing {0% { background-color: #1890ff; }50%, 100% { background-color: rgba(24, 144, 255, 0.2); }
}

 2. chat.js

// 对话管理
let isGenerating = false;// 发送消息
async function sendMessage() {if (isGenerating) return;const inputBox = document.getElementById('inputBox');const message = inputBox.value.trim();if (!message) return;// 清空输入框inputBox.value = '';toggleLoading(true);try {// 添加用户消息appendMessage(message, 'user');// 调用APIconst response = await fetch('/api/chat', {method: 'POST',headers: {'Content-Type': 'text/plain'},body: message});if (!response.ok) {throw new Error(`HTTP错误: ${response.status}`);}const result = await response.text();appendMessage(result, 'bot');} catch (error) {appendMessage(`请求失败: ${error.message}`, 'error');} finally {toggleLoading(false);}
}// 添加消息到历史
function appendMessage(content, type = 'bot') {const history = document.getElementById('chatHistory');const messageDiv = document.createElement('div');messageDiv.className = `message ${type}-message`;const avatar = document.createElement('div');avatar.className = 'avatar';avatar.textContent = type === 'user' ? '👤' : '🤖';const contentDiv = document.createElement('div');contentDiv.className = 'content';contentDiv.innerHTML = marked.parse(content); // 使用Markdown解析messageDiv.appendChild(avatar);messageDiv.appendChild(contentDiv);history.appendChild(messageDiv);// 自动滚动到底部history.scrollTop = history.scrollHeight;
}// 加载状态控制
function toggleLoading(show) {const loading = document.getElementById('loading');loading.style.display = show ? 'block' : 'none';isGenerating = show;
}// 使用localStorage(历史记录持久化到本地)
function saveHistory() {localStorage.setItem('chatHistory',document.getElementById('chatHistory').innerHTML);
}// 文本打字效果(打字机效果)
function typewriterEffect(element, text, speed = 30) {let i = 0;function type() {if (i < text.length) {element.innerHTML += text.charAt(i);i++;setTimeout(type, speed);}}type();
}// 回车发送(Shift+回车换行)
document.getElementById('inputBox').addEventListener('keydown', (e) => {if (e.key === 'Enter' && !e.shiftKey) {e.preventDefault();sendMessage();}
});

 3. index.html

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>DeepSeek对话助手</title><link rel="stylesheet" href="css/chat.css"><!-- 添加highlight.js --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/styles/default.min.css"><!-- 添加Markdown解析库 --><script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head>
<body>
<div class="chat-container"><!-- 对话历史区域 --><div class="chat-history" id="chatHistory"><div class="message bot-message"><div class="avatar">🤖</div><div class="content">您好!我是DeepSeek助手,有什么可以帮您?</div></div></div><!-- 输入区域 --><div class="input-area"><textareaid="inputBox"placeholder="输入您的问题..."rows="2"@keydown.enter.prevent="handleSend"></textarea><button id="sendBtn" onclick="sendMessage()">发送</button></div><!-- 加载状态 --><div class="loading" id="loading"><div class="dot-flashing"></div></div>
</div><script src="js/chat.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.0/highlight.min.js"></script>
</body>
</html>

        前端部分的代码到这里就结束了,后续根据个人需求进行修改和添加。

四、运行 

        利用上面展示的代码将SpringBoot工程构建好,接着再idea上运行,然后在浏览器中输入地址:localhost:8080即可访问到项目的前端页面,试着在对话框输入:“请你使用java写一个helloword程序”,结果如下:

        如果你调用接口报错,错误代码为402,说明你没有充值,要到DeepSeek的API开放平台进行充值,最低只需一元,充值过后就可以正常调用了。

相关文章:

SpringBoot项目接入DeepSeek

在这个demo当中&#xff0c;我使用的是JDK8Spring Boot 2.6.x&#xff0c;下面直接给大家附上完整的代码。 一、项目结构 deepseek - demo/ ├── src/ │ ├── main/ │ │ ├── java/ │ │ │ └── cn/ │ │ │ └── mzl/ │ │ │ …...

C++ lambda表达式的捕获原理

目录 C Lambda表达式捕获机制的详细原理分析Lambda的本质机制关键实现细节特殊捕获方式[ ]空捕获[&]全引用捕获[]全值(拷贝)捕获混合捕获[,&variable]拷贝及部分引用捕获[&,variable]引用及部分拷贝捕获 显式捕获[variable]拷贝捕获部分变量[&variable]引用捕获…...

修改图像分辨率

在这个教程中&#xff0c;您将学习如何使用Python和深度学习技术来调整图像的分辨率。我们将从基础的图像处理技术开始&#xff0c;逐步深入到使用预训练的深度学习模型进行图像超分辨率处理。 一、常规修改方法 1. 安装Pillow库 首先&#xff0c;你需要确保你的Python环境中…...

【面板数据】公开整理-各省刑事案件统计数据集(2011-2023年)

刑事案件数量是衡量一个地区社会治安状况的重要指标。近年来&#xff0c;我国各地在推进法治建设和社会治理现代化的背景下&#xff0c;刑事案件的数量呈现出明显的区域差异和年度波动&#xff0c;通过年度案件数据&#xff0c;可以反映出社会安全水平的变化趋势&#xff0c;为…...

ABAP使用GET_TAX_PERCENTAGE 函数取税率

ABAP使用GET_TAX_PERCENTAGE 函数取税率 今天在做含税价的时候查到的&#xff0c;记录一下。S4 Hana 的环境。 先DATA一个 ftaxp GET_TAX_PERCENTAGE 函数&#xff0c;实例为采购订单进项税。 OK&#xff0c;搞定。...

鞅与停时 - 一种特别的概率论问题

讨论一个有趣的概率问题&#xff1a; [P3334 ZJOI2013] 抛硬币 - 洛谷 实际上是一个猴子打字问题&#xff0c;考虑一直无规律随即打字的猴子&#xff0c;键盘上只有A-Z一共26个字母&#xff0c;对于一个特定的字符串 S S S &#xff1a; ABCABCAB &#xff0c;能否在有限的打…...

Android 有线网开发调试总结

Android 有线网开发调试总结 文章目录 Android 有线网开发调试总结一、前言二、有线网开发1、开关2、相关日志&#xff08;3&#xff09;相关广播&#xff08;4&#xff09;demo示例 三、其他1、Android 有线网开发调试小结2、Android13 有线网开关研究3、Android9、11 有线网络…...

.net在DB First模式使用pgsql

nuget要安装&#xff1a; Npgsql.EntityFrameworkCore.PostgreSQL Microsoft.EntityFrameworkCore.Tools vs2022-->工具-->nuget包管理器-->程序包管理器控制台-->输入命令&#xff1a; Scaffold-DbContext "Hostlocalhost;Databasemydatabase;Usernamemyu…...

Spring Boot 中如何解决 CORS 问题(详解)

在前后端分离的开发模式中&#xff0c;前端调用后端接口时&#xff0c;经常会遇到 跨域资源共享&#xff08;CORS&#xff09; 的问题。Spring Boot 作为常用的后端框架&#xff0c;提供了多种方式来优雅地解决这个问题。本文将全面介绍 Spring Boot 中处理 CORS 的常见方法、原…...

深度学习:智能车牌识别系统(python)

这是一个基于opencv的智能车牌识别系统,有GUI界面。程序能自动识别图片中的车牌号码,并支持中文和英文字符识别,支持选择本地图片文件,支持多种图片格式(jpg、jpeg、png、bmp、gif)。 下面,我将按模块功能对代码进行分段说明: 1. 导入模块部分 import tkinter as tk…...

STM32开发printf函数支持

1、printf函数支持 1、避免使用半主机模式&#xff1a;两种方法:微库法、代码法 2、实现fputc函数&#xff1a;实现单个字符输出 2、半主机模式简介 用于 ARM 目标的一种机制&#xff0c;可将来自应用程序代码的输入/输出请求传送至运行调试器的主机 简单说:就是通过仿真器实…...

解决 Chrome 与 Chromedriver 版本不一致问题的方法

目录 常见错误处理 处理方案&#xff1a; 1. 自动版本匹配方法 使用 webdriver-manager 库&#xff08;推荐&#xff09; 2. 手动版本管理方法 检查并匹配版本 3. 版本兼容性解决方案 使用兼容性表 4. 自动更新策略 定期检查更新脚本 5. Docker 容器化方案 最佳实践建…...

CPU的基本认识

为大家介绍CPU的基本概念&#xff0c;例如&#xff1a;CPU的型号认识、什么是时钟周期、物理核和逻辑核、缓存、TLB缓存的概念&#xff0c;可以帮助大家对cpu有个概念性的认识&#xff0c;选择电脑的时候可以看懂CPU的参数和理解基本原理。 CPU的基本认识 个人CPU型号介绍工作频…...

UGUI如何使用EventTrigger

前言 在 Unity 的 UGUI 系统中,EventTrigger 是一个强大的组件,允许开发者监听和处理多种 UI 交互事件。以下是详细的使用方法、示例代码、优缺点分析以及注意事项。 一、EventTrigger 基本用法 1. 添加 EventTrigger 组件 在 Unity 编辑器中选中 UI 对象(如 But…...

101alpha_第4个

(-1 * ts_rank(rank(low), 9)) 这里的low是每日的最低价。 各函数及整体含义解释 1. rank(low) 在金融分析场景里&#xff0c;low 通常代表股票在每个交易日中的最低价。rank(low) 会对一段时间内的最低价数据进行排序&#xff0c;并为每个数据赋予一个排名。比如&#xff0c;…...

5月13日观测云发布会:这一次,我们不只是发布产品

01&#xff5c;为什么举办这场发布会&#xff1f; 在生成式 AI 席卷一切、业务系统愈发复杂的时代&#xff0c;我们发现&#xff1a; 传统的监控观测已经无法满足企业对性能、安全、智能的统一诉求&#xff1b;每一个企业&#xff0c;都在经历从“看得到”到“看得懂”的跃迁&…...

【IP101】图像分割技术全解析:从传统算法到深度学习的进阶之路

图像分割详解 ✂️ 欢迎来到图像处理的"手术室"&#xff01;在这里&#xff0c;我们将学习如何像外科医生一样精准地"切割"图像。让我们一起探索这个神奇的图像"手术"世界吧&#xff01;&#x1f3e5; 目录 &#x1f4d1; 1. 图像分割简介2. 阈…...

华为设备链路聚合实验:网络工程实战指南

链路聚合就像为网络搭建 “并行高速路”&#xff0c;既能扩容带宽&#xff0c;又能保障链路冗余&#xff0c;超实用&#xff01; 一、实验拓扑速览 图中两台交换机 LSW1 和 LSW2&#xff0c;PC1、PC2 归属 VLAN 10&#xff0c;PC3 归属 VLAN 30。LSW1 与 LSW2 通过 GE0/0/1、…...

C24-数组

数组的引入:方便对同一类型的数据进行管理(一个班级里的45个同学、一个篮子里的12个苹果)数组的定义: 数据类型 数组名[常量表达式(也就是元素的个数)];int a[10]; //这里定义了一个能存放10个元素的整形数组数组初始化 完全初始化 int arr[3]{5,6,8};部分初始化 int arr[10]{…...

Vue 项目中长按保存图片功能实现指南

在移动互联网应用中&#xff0c;用户常常有保存页面特定内容为图片的需求&#xff0c;比如保存二维码、海报等。在 Vue 项目开发中&#xff0c;如何实现长按保存图片的功能&#xff1f;本文将结合具体代码&#xff0c;详细讲解在 Vue 项目中通过长按操作保存图片的技术实现与应…...

行业先锋:六款产品的实战表现

行业先锋&#xff1a;六款产品的实战表现  北京先智先行科技有限公司&#xff0c;销售着“先知大模型”、“先行AI商学院”“先知AIGC超级工场”这三个旗舰产品&#xff0c;在行业内崭露头角。旗下的先知A1、先知大模型等更是备受关注。  先知大模型&#xff0c;作为核心产…...

RS485与Profibus网关自由口数据互换技巧

RS485与Profibus网关自由口数据互换技巧 兴达易控RS485转Profibus网关在自由口模式下的数据互换&#xff0c;是工业自动化领域内一项关键的技术应用&#xff0c;它实现了不同通信协议设备之间的有效连接与数据交换。在现代工业生产中&#xff0c;众多设备和系统往往采用不同的…...

java复杂度,包装类,泛型解析

如何衡量代码的好坏&#xff1f; 评价代码的好坏我们使用算法效率来判断&#xff0c;而算法效率分两种&#xff1a; 算法效率&#xff1a; 第一种是时间效率&#xff0c;第二种是空间效率&#xff0c;时间效率被称为时间复杂度&#xff0c;⽽空间效率被称作空间复杂度。 时间…...

K8S安装部署(v1.27.6)

一、机器配置 系统版本主机名IP基于服务centos 7.9k8s-master192.168.163.104dockerk8s-node1192.168.163.105k8s-node2192.168.163.106注:以上3台机器都是2C4G的虚拟机,仅供测试使用 docker部署可以参考:docker 部署 二、其他环境配置 #1、关闭防火墙 systemctl stop fir…...

Debezium BinaryLogClient详解

Debezium BinaryLogClient详解 1. 类的作用与功能 1.1 核心作用 BinaryLogClient是Debezium中负责与MySQL服务器建立和维护Binlog连接的核心类,主要功能包括: 连接管理:建立和维护与MySQL服务器的Binlog连接事件监听:接收和处理Binlog事件心跳保活:维护连接活跃状态断线…...

Leetcode 刷题记录 09 —— 链表第三弹

本系列为笔者的 Leetcode 刷题记录&#xff0c;顺序为 Hot 100 题官方顺序&#xff0c;根据标签命名&#xff0c;记录笔者总结的做题思路&#xff0c;附部分代码解释和疑问解答&#xff0c;01~07为C语言&#xff0c;08及以后为Java语言。 01 合并 K 个升序链表 /*** Definitio…...

加速项目落地(Trae编辑器)

目录 vscode安装python支持 vscode常用插件 Trae编辑器 两个界面合成 补充&#xff08;QT开发的繁琐&#xff09; AI编程哪家强&#xff1f;Cursor、Trae深度对比&#xff0c;超详细&#xff01; - 知乎 Trae兼容vscode的插件&#xff0c;我们可以先在vscode里面装好再一…...

vue3的页面跳转方法汇总(路由跳转,组件跳转)

1.组件跳转 使用router-link组件进行组件导航&#xff08;无需引入该组件&#xff0c;可直接使用&#xff09;&#xff0c;to后面跟组件路由。如果想要在当前页显示跳转的组件&#xff0c;可以通过<router-view>来显示当前路由匹配到的组件&#xff0c;也可以不使用<r…...

C++回顾 Day5

自实现string完整版 my_string.h using namespace std; class mystr{public://mystr();mystr(const char * new_str nullptr);mystr(const mystr & another);char * c_str();~mystr();mystr& operator(const mystr & another);mystr operator(const mystr &…...

OpenMVS 的编译与运行

Title: OpenMVS 的编译与运行 文章目录 I. 编译与准备1. 获得源码2. wiki3. 退出 Conda 环境4. 编译5. 数据准备 II. 命令了解1. 稠密重建 DensifyPointCloud2. 曲面重建 ReconstructMesh3. 网格优化 RefineMesh4. 纹理贴图 TextureMesh III. 命令运行1. 运行稠密重建2. 运行网…...

@Transactional注解的使用

目录 一.介绍 1.使用Transactional注解的位置 2.Transactional注解的作用 二.举例 1.需求场景 2.做法 3.效果展示 三.简单总结 一.介绍 1.使用Transactional注解的位置 我们在Java开发中&#xff0c;一般在service层的方法上&#xff0c;使用Transactional注解&#x…...

路由器NAT回流踩坑

路由器 H3C GR-3000AX-U 不支持NAT回流 核心问题定位 外网访问 ✅ 非Docker服务&#xff08;直接运行在宿主机上的服务&#xff09;可以访问❌ Docker服务 无法访问 内网访问 ✅ 内网IP访问&#xff08;无论Docker还是非Docker&#xff09;正常❌ 内网通过公网IP访问 全部失败…...

如何创建RDD

创建RDD&#xff08;Resilient Distributed Dataset&#xff09;主要有以下三种方法&#xff1a; 1. 从集合创建RDD 通过将本地集合&#xff08;如列表、数组&#xff09;传递给SparkContext的parallelize方法&#xff0c;可以将本地数据转换为RDD。这种方式通常用于测试或开…...

PTS-G5K13M RF Generator 5kW / 13MHz 射频电源User s Manual

PTS-G5K13M RF Generator 5kW / 13MHz 射频电源User s Manual...

vue3父组件调用子组件方法

需求&#xff1a;在vue3中需要在父组件调用子组件的方法 思路&#xff1a;通过ref和defineExpose直接暴露给父组件 1.子组件暴露表单验证方法 <template><a-form ref"formRef" :model"formState" :rules"rules"><a-form-item …...

Python小酷库系列:5个常用的dict属性化访问扩展库

5个常用的dict属性化访问扩展库 嵌套结构高级功能性能综合建议 在前面我们详细讲解了 Box和 Munch这两个dict属性化访问的扩展库&#xff0c;总体而言它们主要用于提升配置文件数据、JSON对象数据的可读性&#xff0c;减少了代码中双引号。在这一领域中还有dotmap、addict 和…...

day009-用户管理专题

文章目录 1. 创建包含时间的文件2. 与用户相关的文件3. 用户分类4. 与用户相关的命令4.1 添加用户4.2 删除用户4.3 查看用户4.4 修改用户密码 5. sudo6. 思维导图7. 老男孩思想-学习方法 1. 创建包含时间的文件 或$()是替换符号&#xff0c;可以将命令的结果作为字符串或变量的…...

微信小程序pinia的应用

情景&#xff1a;院校列表的关注状态的实时更新 新建一个ts文件存储关注状态&#xff0c;用于集中管理用户“已关注院校”的相关状态和操作 import {definStore} from pinia; import type { College_records } from /types/university;export const useFocusCollegeStore de…...

LWIP的超时事件笔记

那个马蜂佬&#xff0c;刚发就给我两个赞 lwIP超时事件处理简介 为每个与外界网络连接的任务都设定了timeout属性&#xff0c;即等待超时时间&#xff0c;例如TCP建立连接超时、ARP缓存表项的时间管理等&#xff0c;都需要超时操作来处理 lwIP超时事件机制 一共有四种 2.1&a…...

如何避免项目结束后知识流失

避免项目结束后知识流失的方法包括&#xff1a;建立项目知识库、实施定期知识回顾与总结、强化团队内部知识共享机制、利用合适的知识管理工具。项目知识库的建设尤其关键&#xff0c;它可帮助团队保留核心经验和方法&#xff0c;确保知识沉淀在组织内部。通过知识库&#xff0…...

【MCP】客户端配置(ollama安装、qwen2.5:0.5b模型安装、cherry-studio安装配置)

【MCP】客户端配置&#xff08;ollama安装、qwen2.5:0.5b模型安装、cherry-studio安装配置&#xff09; 客户端配置&#xff08;1&#xff09;下载安装ollama&#xff08;2&#xff09;安装qwen2.5:0.5b模型&#xff08;3&#xff09;安装配置cherry-studio 客户端配置 &#…...

Media3 中 Window 的时间相关属性详解

AndroidX Media3 的 Timeline.Window 类中&#xff0c;与时间相关的属性描述了媒体播放窗口&#xff08;window&#xff09;在时间维度上的关键信息。这些属性帮助开发者理解媒体的播放范围、起始点、持续时间以及与设备时间或直播流的同步关系。 Timeline.Window 的时间相关属…...

C 语言编码规范

在 C 语言开发过程中&#xff0c;遵循编码规范不仅能提高代码的可读性、可维护性&#xff0c;还能减少潜在的错误&#xff0c;提升团队协作效率。以下从多个维度详细阐述 C 语言编码过程中需要注意的规范要点。 一、命名规范 变量命名 变量命名应做到见名知意&#xff0c;采用…...

嵌入式开发学习日志Day15

一、指针指向字符型数组 &#xff08;1&#xff09;【const】&#xff1a;在指针变量中使用时&#xff0c;无法通过该指针修改被指向的变量&#xff1b; &#xff08;2&#xff09;【const】&#xff1a;关键字&#xff0c;在C和C中&#xff0c;能加就加&#xff0c;加了一定…...

从人脸扫描到实时驱动,超写实数字分身技术解析

在元宇宙浪潮中&#xff0c;数字人、虚拟数字人等新兴概念逐渐走进大众视野&#xff0c;其中数字分身作为虚拟数字人的细分领域&#xff0c;正引发广泛关注。数字分身依托人工智能与虚拟现实技术&#xff0c;能基于真人信息进行1:1复刻&#xff0c;具备与真人高度相似的外貌、声…...

Vue3 自定义指令的原理,以及应用

文章目录 前言一、原理说明二、注册与使用1. 全局注册2. 局部注册3. 使用方式 三、典型应用场景四、案例&#xff1a;权限控制指令五、注意事项 v-draggable✅ 目标效果&#xff1a;&#x1f9e9; 1. 自定义指令定义&#x1f9f1; 2. 在项目中注册&#x1f9ea; 3. 使用示例&am…...

306.检查是否所有A都在B之前

2124. 检查是否所有 A 都在 B 之前 - 力扣&#xff08;LeetCode&#xff09; class Solution {public boolean checkString(String s) {return !s.contains("ba");} } class Solution(object):def checkString(self, s):return s.find("ba")-1...

适合java程序员的Kafka消息中间件实战

创作的初心&#xff1a; 我们在学习kafka时&#xff0c;都是基于大数据的开发而进行的讲解&#xff0c;这篇文章为java程序员为核心&#xff0c;助力大家掌握kafka实现。 什么是kafka: 历史&#xff1a; 诞生与开源&#xff08;2010 - 2011 年&#xff09; 2010 年&#xf…...

当体育数据API遇上WebSocket:一场技术互补的「攻防战」

在世界杯决赛的最后一分钟&#xff0c;你正通过手机观看直播。突然&#xff0c;解说员大喊“球进了&#xff01;”&#xff0c;但你的屏幕却卡在对方半场的回放画面——这种「延迟乌龙」的尴尬&#xff0c;正是实时体育应用面临的终极挑战。 在体育数字化浪潮下&#xff0c;用…...

1:点云处理—三种显示方法(自建点云)

1.彩色显示 *读取三维点云 dev_get_window(WindowHandle)dev_open_window(0, 0, 512, 512, black, WindowHandle1) read_object_model_3d(./19-12-26/t.ply, m, [], [], ObjectModel3D, Status)Instructions[0] : Rotate: Left button Instructions[1] : Zoom: Shift left…...