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

Node.js + MongoDB + Vue 3 全栈应用项目开发

​🌈个人主页:前端青山
🔥系列专栏:node.js篇
🔖人终将被年少不可得之物困其一生

依旧青山,本期给大家带来node.js篇专栏内容:Node.js + MongoDB + Vue 3 全栈应用项目开发

在前几篇文章中,我们已经为 Node.js 应用添加了身份验证、CORS 配置、缓存机制、性能监控、限流功能和日志优化。本文将继续在这个基础上,逐步构建一个完整的 Node.js + MongoDB + Vue 3 全栈应用。我们将从项目结构设计、前后端交互、数据模型设计等方面入手,逐步实现一个功能完善的全栈应用。

目录

1. 项目概述

2. 项目结构设计

3. 数据模型设计

3.1 用户模型

3.2 任务模型

4. 后端 API 开发

4.1 用户模块

4.1.1 用户注册

4.1.2 用户登录

4.1.3 获取用户信息

4.2 项目模块

4.2.1 创建任务

4.2.2 获取任务列表

4.2.3 更新任务

4.2.4 删除任务

5. 前端 Vue 3 应用开发

5.1 项目初始化

5.2 组件开发

5.2.1 登录组件

5.2.2 注册组件

5.2.3 任务列表组件

5.3 状态管理

6. 前后端联调

6.1 路由配置

6.2 主页组件

6.3 登录和注册页面

7. 部署与测试

7.1 部署后端

7.2 部署前端

7.3 测试

8. 总结与展望

1. 项目概述

我们的目标是构建一个简单的任务管理应用,用户可以注册、登录、创建和管理任务。应用的主要功能包括:

  • 用户注册和登录
  • 用户信息管理
  • 任务创建、编辑和删除
  • 任务列表展示

2. 项目结构设计

为了保持项目的清晰和可维护性,我们将项目分为前后端两部分。项目结构如下:

task-manager/
├── backend/
│   ├── node_modules/
│   ├── src/
│   │   ├── controllers/
│   │   ├── models/
│   │   ├── routes/
│   │   ├── middlewares/
│   │   ├── config/
│   │   ├── app.js
│   │   ├── server.js
│   ├── .env
│   ├── package.json
│   └── README.md
├── frontend/
│   ├── node_modules/
│   ├── public/
│   │   └── index.html
│   ├── src/
│   │   ├── assets/
│   │   ├── components/
│   │   ├── views/
│   │   ├── store/
│   │   ├── router/
│   │   ├── App.vue
│   │   └── main.js
│   ├── .env
│   ├── package.json
│   └── README.md
├── .gitignore
└── README.md

3. 数据模型设计

我们将使用 MongoDB 作为数据库,定义两个主要的数据模型:用户和任务。

3.1 用户模型

用户模型包含以下字段:

  • username:用户名
  • email:邮箱
  • password:密码(加密存储)
  • createdAt:创建时间
  • updatedAt:更新时间

在 backend/src/models/user.js 中定义用户模型:

const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');const UserSchema = new mongoose.Schema({username: { type: String, required: true, unique: true },email: { type: String, required: true, unique: true },password: { type: String, required: true },createdAt: { type: Date, default: Date.now },updatedAt: { type: Date, default: Date.now }
});UserSchema.pre('save', async function(next) {if (!this.isModified('password')) return next();this.password = await bcrypt.hash(this.password, 10);next();
});UserSchema.methods.comparePassword = async function(candidatePassword) {return await bcrypt.compare(candidatePassword, this.password);
};const User = mongoose.model('User', UserSchema);module.exports = User;
3.2 任务模型

任务模型包含以下字段:

  • title:任务标题
  • description:任务描述
  • status:任务状态(未完成、已完成)
  • userId:关联用户 ID
  • createdAt:创建时间
  • updatedAt:更新时间

在 backend/src/models/task.js 中定义任务模型:

const mongoose = require('mongoose');const TaskSchema = new mongoose.Schema({title: { type: String, required: true },description: { type: String, required: true },status: { type: String, enum: ['未完成', '已完成'], default: '未完成' },userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },createdAt: { type: Date, default: Date.now },updatedAt: { type: Date, default: Date.now }
});const Task = mongoose.model('Task', TaskSchema);module.exports = Task;

4. 后端 API 开发

4.1 用户模块
4.1.1 用户注册

在 backend/src/controllers/userController.js 中实现用户注册功能:

const User = require('../models/user');
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');exports.register = async (req, res) => {const { username, email, password } = req.body;try {let user = await User.findOne({ email });if (user) {return res.status(400).json({ msg: 'User already exists' });}user = new User({ username, email, password });await user.save();const payload = { user: { id: user.id } };const token = jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: '1h' });res.status(201).json({ token });} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.1.2 用户登录

在 backend/src/controllers/userController.js 中实现用户登录功能:

exports.login = async (req, res) => {const { email, password } = req.body;try {let user = await User.findOne({ email });if (!user) {return res.status(400).json({ msg: 'Invalid credentials' });}const isMatch = await user.comparePassword(password);if (!isMatch) {return res.status(400).json({ msg: 'Invalid credentials' });}const payload = { user: { id: user.id } };const token = jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: '1h' });res.json({ token });} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.1.3 获取用户信息

在 backend/src/controllers/userController.js 中实现获取用户信息功能:

exports.getUser = async (req, res) => {try {const user = await User.findById(req.user.id).select('-password');if (!user) {return res.status(404).json({ msg: 'User not found' });}res.json(user);} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.2 项目模块
4.2.1 创建任务

在 backend/src/controllers/taskController.js 中实现创建任务功能:

const Task = require('../models/task');exports.createTask = async (req, res) => {const { title, description } = req.body;try {const task = new Task({ title, description, userId: req.user.id });await task.save();res.status(201).json(task);} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.2.2 获取任务列表

在 backend/src/controllers/taskController.js 中实现获取任务列表功能:

exports.getTasks = async (req, res) => {try {const tasks = await Task.find({ userId: req.user.id }).sort({ createdAt: -1 });res.json(tasks);} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.2.3 更新任务

在 backend/src/controllers/taskController.js 中实现更新任务功能:

exports.updateTask = async (req, res) => {const { title, description, status } = req.body;try {let task = await Task.findById(req.params.id);if (!task) {return res.status(404).json({ msg: 'Task not found' });}if (task.userId.toString() !== req.user.id) {return res.status(401).json({ msg: 'Not authorized' });}task.title = title;task.description = description;task.status = status;await task.save();res.json(task);} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};
4.2.4 删除任务

在 backend/src/controllers/taskController.js 中实现删除任务功能:

exports.deleteTask = async (req, res) => {try {let task = await Task.findById(req.params.id);if (!task) {return res.status(404).json({ msg: 'Task not found' });}if (task.userId.toString() !== req.user.id) {return res.status(401).json({ msg: 'Not authorized' });}await task.remove();res.json({ msg: 'Task deleted' });} catch (err) {console.error(err.message);res.status(500).send('Server error');}
};

5. 前端 Vue 3 应用开发

5.1 项目初始化

首先,我们需要初始化 Vue 3 项目。打开终端,导航到 frontend 目录,然后运行以下命令:

npm init vue@latest

按照提示完成项目初始化。安装完成后,进入项目目录并安装依赖:

cd frontend npm install
5.2 组件开发
5.2.1 登录组件

在 frontend/src/components/Login.vue 中创建登录组件:

<template><div class="login"><h2>Login</h2><form @submit.prevent="handleLogin"><div class="form-group"><label for="email">Email</label><input type="email" v-model="email" required /></div><div class="form-group"><label for="password">Password</label><input type="password" v-model="password" required /></div><button type="submit">Login</button></form></div>
</template><script>
import axios from 'axios';export default {data() {return {email: '',password: ''};},methods: {async handleLogin() {try {const response = await axios.post('http://localhost:3000/auth/login', {email: this.email,password: this.password});localStorage.setItem('token', response.data.token);this.$router.push('/tasks');} catch (error) {alert('Login failed');}}}
};
</script><style scoped>
/* 添加一些样式 */
</style>
5.2.2 注册组件

在 frontend/src/components/Register.vue 中创建注册组件:

<template><div class="register"><h2>Register</h2><form @submit.prevent="handleRegister"><div class="form-group"><label for="username">Username</label><input type="text" v-model="username" required /></div><div class="form-group"><label for="email">Email</label><input type="email" v-model="email" required /></div><div class="form-group"><label for="password">Password</label><input type="password" v-model="password" required /></div><button type="submit">Register</button></form></div>
</template><script>
import axios from 'axios';export default {data() {return {username: '',email: '',password: ''};},methods: {async handleRegister() {try {await axios.post('http://localhost:3000/auth/register', {username: this.username,email: this.email,password: this.password});this.$router.push('/login');} catch (error) {alert('Registration failed');}}}
};
</script><style scoped>
/* 添加一些样式 */
</style>

5.2.3 任务列表组件

在 frontend/src/components/TaskList.vue 中创建任务列表组件:

<template><div class="task-list"><h2>Tasks</h2><ul><li v-for="task in tasks" :key="task._id"><span>{{ task.title }}</span><button @click="deleteTask(task._id)">Delete</button></li></ul><form @submit.prevent="createTask"><div class="form-group"><label for="title">Title</label><input type="text" v-model="newTask.title" required /></div><div class="form-group"><label for="description">Description</label><input type="text" v-model="newTask.description" required /></div><button type="submit">Create Task</button></form></div>
</template><script>
import axios from 'axios';export default {data() {return {tasks: [],newTask: {title: '',description: ''}};},methods: {async fetchTasks() {const response = await axios.get('http://localhost:3000/tasks', {headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }});this.tasks = response.data;},async createTask() {await axios.post('http://localhost:3000/tasks', this.newTask, {headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }});this.newTask = { title: '', description: '' };this.fetchTasks();},async deleteTask(id) {await axios.delete(`http://localhost:3000/tasks/${id}`, {headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }});this.fetchTasks();}},created() {this.fetchTasks();}
};
</script><style scoped>
/* 添加一些样式 */
</style>
5.3 状态管理

为了更好地管理应用的状态,我们将使用 Vuex。首先,安装 Vuex:

npm install vuex@next

在 frontend/src/store/index.js 中创建 Vuex 存储:

import { createStore } from 'vuex';export default createStore({state: {token: localStorage.getItem('token') || null},mutations: {setToken(state, token) {state.token = token;localStorage.setItem('token', token);},clearToken(state) {state.token = null;localStorage.removeItem('token');}},actions: {login({ commit }, token) {commit('setToken', token);},logout({ commit }) {commit('clearToken');}},getters: {isAuthenticated: state => !!state.token}
});

6. 前后端联调

确保 MongoDB 和后端服务已启动。在 backend 目录下运行以下命令启动后端服务:

npm start

在 frontend 目录下运行以下命令启动前端开发服务器:

npm run serve
6.1 路由配置

为了更好地组织应用的路由,我们需要在 frontend/src/router/index.js 中配置路由:

import { createRouter, createWebHistory } from 'vue-router';
import Home from '../views/Home.vue';
import Login from '../components/Login.vue';
import Register from '../components/Register.vue';
import TaskList from '../components/TaskList.vue';
import store from '../store';const routes = [{path: '/',name: 'Home',component: Home},{path: '/login',name: 'Login',component: Login,meta: { requiresAuth: false }},{path: '/register',name: 'Register',component: Register,meta: { requiresAuth: false }},{path: '/tasks',name: 'Tasks',component: TaskList,meta: { requiresAuth: true }}
];const router = createRouter({history: createWebHistory(process.env.BASE_URL),routes
});router.beforeEach((to, from, next) => {if (to.meta.requiresAuth && !store.getters.isAuthenticated) {next('/login');} else {next();}
});export default router;
6.2 主页组件

在 frontend/src/views/Home.vue 中创建主页组件:

<template><div class="home"><h1>Welcome to the Task Manager</h1><p>Please <router-link to="/login">login</router-link> or <router-link to="/register">register</router-link> to get started.</p></div>
</template><script>
export default {name: 'Home'
};
</script><style scoped>
/* 添加一些样式 */
</style>
6.3 登录和注册页面

在 frontend/src/App.vue 中设置默认路由:

<template><div id="app"><router-view></router-view></div>
</template><script>
export default {name: 'App'
};
</script><style>
/* 添加一些全局样式 */
</style>

7. 部署与测试

7.1 部署后端

将后端应用部署到云服务器或使用 Docker 容器化部署。这里以 Docker 为例,创建 Dockerfile 文件:

# 使用官方 Node.js 运行时镜像
FROM node:14# 设置工作目录
WORKDIR /app# 复制 package.json 和 package-lock.json
COPY package*.json ./# 安装依赖
RUN npm install# 复制应用代码
COPY . .# 暴露端口
EXPOSE 3000# 启动应用
CMD ["node", "src/server.js"]

构建并运行 Docker 容器:

docker build -t task-manager-backend .
docker run -d -p 3000:3000 task-manager-backend
7.2 部署前端

将前端应用构建为生产版本,并部署到静态文件服务器。例如,使用 Nginx:

npm run build

创建 nginx.conf 文件:

server {listen 80;server_name your-domain.com;location / {root /path/to/dist;try_files $uri $uri/ /index.html;}
}

启动 Nginx 服务:

sudo nginx -c /path/to/nginx.conf
7.3 测试

确保所有功能正常工作,包括用户注册、登录、任务创建、编辑和删除。可以使用 Postman 或浏览器进行测试。

8. 总结与展望

通过本文,我们成功构建了一个完整的 Node.js + MongoDB + Vue 3 全栈应用。这个应用实现了用户注册、登录、任务管理等功能。未来可以进一步扩展和优化,例如:

  • 添加更多的用户权限管理
  • 实现任务的分类和标签管理
  • 增加实时通知功能
  • 优化前端用户体验

希望本文对你有所帮助,祝你在全栈开发的道路上越走越远!

相关文章:

Node.js + MongoDB + Vue 3 全栈应用项目开发

​&#x1f308;个人主页&#xff1a;前端青山 &#x1f525;系列专栏&#xff1a;node.js篇 &#x1f516;人终将被年少不可得之物困其一生 依旧青山,本期给大家带来node.js篇专栏内容:Node.js MongoDB Vue 3 全栈应用项目开发 在前几篇文章中&#xff0c;我们已经为 Node.j…...

【云原生开发】如何通过client-go来操作K8S集群

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

CSS基础知识六(浮动的高度塌陷问题及解决方案)

目录 1.浮动高度塌陷概念 2.下面是几种解决高度塌陷的几种方案&#xff1a; 解决方案一&#xff1a; 解决方案二&#xff1a; 解决方案三&#xff1a; 1.浮动高度塌陷概念 在CSS中&#xff0c;高度塌陷问题指的是父元素没有正确地根据其内部的浮动元素或绝对定位元素来计…...

开源模型应用落地-glm模型小试-glm-4-9b-chat-vLLM集成(四)

一、前言 GLM-4是智谱AI团队于2024年1月16日发布的基座大模型&#xff0c;旨在自动理解和规划用户的复杂指令&#xff0c;并能调用网页浏览器。其功能包括数据分析、图表创建、PPT生成等&#xff0c;支持128K的上下文窗口&#xff0c;使其在长文本处理和精度召回方面表现优异&a…...

.net为什么要在单独的项目中定义扩展方法?C#

使用 扩展方法&#xff08;Extension Methods&#xff09; 和创建 扩展类&#xff08;Extension Class&#xff09; 在 C# 中有几个特定的目的&#xff0c;主要是为了提高代码的可扩展性、灵活性和可读性。让我们来详细解释这些概念以及为什么扩展类需要是静态的。 为什么使用…...

动态规划 —— dp 问题-打家劫舍II

1.打家劫舍II 题目链接&#xff1a; 213. 打家劫舍 II - 力扣&#xff08;LeetCode&#xff09;https://leetcode.cn/problems/house-robber-ii/ 2. 题目解析 通过分类讨论&#xff0c;将环形问题转换为两个线性的“打家劫舍|” 当偷第一个位置的时候&#xff0c;rob1在&#…...

Java基础-组件及事件处理(上)

(创作不易&#xff0c;感谢有你&#xff0c;你的支持&#xff0c;就是我前行的最大动力&#xff0c;如果看完对你有帮助&#xff0c;请留下您的足迹&#xff09; 目录 Swing 概述 MVC 架构 Swing 特点 控件 SWING UI 元素 JFrame SWING 容器 说明 常用方法 示例&a…...

Python实例:爱心代码

前言 在编程的奇妙世界里,代码不仅仅是冰冷的指令集合,它还可以成为表达情感、传递温暖的独特方式。今天,我们将一同探索用 Python 语言绘制爱心的神奇之旅。 爱心,这个象征着爱与温暖的符号,一直以来都在人类的情感世界中占据着特殊的地位。而通过 Python 的强大功能,…...

图解大模型训练系列:序列并行3,Ring Attention

在序列并行系列中&#xff0c;我们将详细介绍下面四种常用的框架/方法&#xff1a; Megatron Sequence Parallelism&#xff1a;本质是想通过降低单卡激活值大小的方式&#xff0c;尽可能多保存激活值&#xff0c;少做重计算&#xff0c;以此提升整体训练速度&#xff0c;一般…...

pyspark基础准备

1.前言介绍 学习目标&#xff1a;了解什么是Speak、PySpark&#xff0c;了解为什么学习PySpark&#xff0c;了解课程是如何和大数据开发方向进行衔接 使用pyspark库所写出来的代码&#xff0c;既可以在电脑上简单运行&#xff0c;进行数据分析处理&#xff0c;又可以把代码无缝…...

Netty报错

问题&#xff1a;因客户反馈Netty版本低&#xff0c;影响性能&#xff0c;建议提升。于是&#xff0c;我将所有Netty版本从4.1.82.Final到4.1.114.Final后&#xff0c;报下面的错误&#xff0c;java.lang.NoClassDefFoundError: io/netty/util/Recycler$EnhancedHandle&#xf…...

Kafka 之顺序消息

前言&#xff1a; 在分布式消息系统中&#xff0c;消息的顺序性是一个重要的问题&#xff0c;也是一个常见的业务场景&#xff0c;那 Kafka 作为一个高性能的分布式消息中间件&#xff0c;又是如何实现顺序消息的呢&#xff1f;本篇我们将对 Kafka 的顺序消息展开讨论。 Kafk…...

Kafka 之批量消息发送消费

前言&#xff1a; 前面我们分享了 Kafka 的一些基础知识&#xff0c;以及 Spring Boot 集成 Kafka 完成消息发送消费&#xff0c;本篇我们来分享一下 Kafka 的批量消息发送消费。 Kafka 系列文章传送门 Kafka 简介及核心概念讲解 Spring Boot 整合 Kafka 详解 Kafka Kafka…...

【大数据学习 | kafka】kafka的偏移量管理

1. 偏移量的概念 消费者在消费数据的时候需要将消费的记录存储到一个位置&#xff0c;防止因为消费者程序宕机而引起断点消费数据丢失问题&#xff0c;下一次可以按照相应的位置从kafka中找寻数据&#xff0c;这个消费位置记录称之为偏移量offset。 kafka0.9以前版本将偏移量信…...

实景三维赋能森林防灭火指挥调度智慧化

森林防灭火工作是保护森林资源和生态环境的重要任务。随着信息技术的发展&#xff0c;实景三维技术在森林防灭火指挥调度中的应用日益广泛&#xff0c;为提升防灭火工作的效率和效果提供了有力支持。 一、森林防灭火面临的挑战 森林火灾具有突发性强、破坏性大、蔓延速度快、…...

【C++课程学习】:string的模拟实现

&#x1f381;个人主页&#xff1a;我们的五年 &#x1f50d;系列专栏&#xff1a;C课程学习 &#x1f389;欢迎大家点赞&#x1f44d;评论&#x1f4dd;收藏⭐文章 目录 一.string的主体框架&#xff1a; 二.string的分析&#xff1a; &#x1f354;构造函数和析构函数&a…...

Linux(VMware + CentOS )设置固定ip

需求&#xff1a;设置ip为 192.168.88.130 先关闭虚拟机 启动虚拟机 查看当前自动获取的ip 使用 FinalShell 通过 ssh 服务远程登录系统&#xff0c;更换到 root 用户 修改ip配置文件 vim /etc/sysconfig/network-scripts/ifcfg-ens33 重启网卡 systemctl restart network …...

安卓 android studio各版本下载地址(官方)

https://developer.android.google.cn/studio/archive 别用中文&#xff0c;右上角的语言切换成英文...

如何在一个 Docker 容器中运行多个进程 ?

在容器化的世界里&#xff0c;Docker 彻底改变了开发人员构建、发布和运行应用程序的方式。Docker 容器封装了运行应用程序所需的所有依赖项&#xff0c;使其易于跨不同环境一致地部署。然而&#xff0c;在单个 Docker 容器中管理多个进程可能具有挑战性&#xff0c;这就是 Sup…...

poetry 配置多个cuda环境心得

操作系统&#xff1a;ubuntu22.04 LTS python版本&#xff1a;3.12.7 最近学习了用poetry配置python虚拟环境&#xff0c;当为不同的项目配置cuda时&#xff0c;会遇到不同的项目使用的cuda版本不一致的情况。 像torch 这样的库&#xff0c;它们会对cuda-toolkit有依赖&…...

Lombok 的 @Data 注解失效,未生成 getter/setter 方法引发的HTTP 406 错误

HTTP 状态码 406 (Not Acceptable) 和 500 (Internal Server Error) 是两类完全不同的错误&#xff0c;它们的含义、原因和解决方法都有显著区别。以下是详细对比&#xff1a; 1. HTTP 406 (Not Acceptable) 含义&#xff1a; 客户端请求的内容类型与服务器支持的内容类型不匹…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

基于Uniapp开发HarmonyOS 5.0旅游应用技术实践

一、技术选型背景 1.跨平台优势 Uniapp采用Vue.js框架&#xff0c;支持"一次开发&#xff0c;多端部署"&#xff0c;可同步生成HarmonyOS、iOS、Android等多平台应用。 2.鸿蒙特性融合 HarmonyOS 5.0的分布式能力与原子化服务&#xff0c;为旅游应用带来&#xf…...

将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?

Otsu 是一种自动阈值化方法&#xff0c;用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理&#xff0c;能够自动确定一个阈值&#xff0c;将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...

在Ubuntu中设置开机自动运行(sudo)指令的指南

在Ubuntu系统中&#xff0c;有时需要在系统启动时自动执行某些命令&#xff0c;特别是需要 sudo权限的指令。为了实现这一功能&#xff0c;可以使用多种方法&#xff0c;包括编写Systemd服务、配置 rc.local文件或使用 cron任务计划。本文将详细介绍这些方法&#xff0c;并提供…...

Redis的发布订阅模式与专业的 MQ(如 Kafka, RabbitMQ)相比,优缺点是什么?适用于哪些场景?

Redis 的发布订阅&#xff08;Pub/Sub&#xff09;模式与专业的 MQ&#xff08;Message Queue&#xff09;如 Kafka、RabbitMQ 进行比较&#xff0c;核心的权衡点在于&#xff1a;简单与速度 vs. 可靠与功能。 下面我们详细展开对比。 Redis Pub/Sub 的核心特点 它是一个发后…...

Java求职者面试指南:Spring、Spring Boot、MyBatis框架与计算机基础问题解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、MyBatis框架与计算机基础问题解析 一、第一轮提问&#xff08;基础概念问题&#xff09; 1. 请解释Spring框架的核心容器是什么&#xff1f;它在Spring中起到什么作用&#xff1f; Spring框架的核心容器是IoC容器&#…...

2025年渗透测试面试题总结-腾讯[实习]科恩实验室-安全工程师(题目+回答)

安全领域各种资源&#xff0c;学习文档&#xff0c;以及工具分享、前沿信息分享、POC、EXP分享。不定期分享各种好玩的项目及好用的工具&#xff0c;欢迎关注。 目录 腾讯[实习]科恩实验室-安全工程师 一、网络与协议 1. TCP三次握手 2. SYN扫描原理 3. HTTPS证书机制 二…...

【 java 虚拟机知识 第一篇 】

目录 1.内存模型 1.1.JVM内存模型的介绍 1.2.堆和栈的区别 1.3.栈的存储细节 1.4.堆的部分 1.5.程序计数器的作用 1.6.方法区的内容 1.7.字符串池 1.8.引用类型 1.9.内存泄漏与内存溢出 1.10.会出现内存溢出的结构 1.内存模型 1.1.JVM内存模型的介绍 内存模型主要分…...

Rust 开发环境搭建

环境搭建 1、开发工具RustRover 或者vs code 2、Cygwin64 安装 https://cygwin.com/install.html 在工具终端执行&#xff1a; rustup toolchain install stable-x86_64-pc-windows-gnu rustup default stable-x86_64-pc-windows-gnu ​ 2、Hello World fn main() { println…...