基于 SSM(Spring + Spring MVC + MyBatis)框架构建电器网上订购系统
基于 SSM(Spring + Spring MVC + MyBatis)框架构建电器网上订购系统可以为用户提供一个方便快捷的购物平台。以下将详细介绍该系统的开发流程,包括需求分析、技术选型、数据库设计、项目结构搭建、主要功能实现以及前端页面设计。

需求分析
电器网上订购系统应具备以下功能:
- 用户注册与登录
- 商品展示与搜索
- 购物车管理
- 订单管理
- 支付接口集成
- 后台管理系统(商品管理、订单管理、用户管理)
技术选型
- 后端:Java、Spring、Spring MVC、MyBatis
- 前端:HTML、CSS、JavaScript、JQuery
- 数据库:MySQL
- 开发工具:IntelliJ IDEA 或 Eclipse
- 服务器:Tomcat
数据库设计
创建数据库表以存储用户信息、商品信息、购物车信息、订单信息等。
用户表(users)
id(INT, 主键, 自增)username(VARCHAR)password(VARCHAR)email(VARCHAR)phone(VARCHAR)
商品表(products)
id(INT, 主键, 自增)name(VARCHAR)description(TEXT)price(DECIMAL)stock(INT)category(VARCHAR)image_url(VARCHAR)
购物车表(cart_items)
id(INT, 主键, 自增)user_id(INT, 外键)product_id(INT, 外键)quantity(INT)
订单表(orders)
id(INT, 主键, 自增)user_id(INT, 外键)order_date(DATETIME)total_price(DECIMAL)status(VARCHAR)
订单详情表(order_details)
id(INT, 主键, 自增)order_id(INT, 外键)product_id(INT, 外键)quantity(INT)price(DECIMAL)
项目结构搭建
-
创建 Maven 项目
- 在 IDE 中创建一个新的 Maven 项目。
- 修改
pom.xml文件,添加必要的依赖项。
-
配置文件
- application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/electronics_store?useSSL=false&serverTimezone=UTC spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.cj.jdbc.Drivermybatis.mapper-locations=classpath:mapper/*.xml - spring-mvc.xml
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd"><context:component-scan base-package="com.electronics"/><mvc:annotation-driven/><bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><property name="prefix" value="/WEB-INF/views/"/><property name="suffix" value=".jsp"/></bean></beans> - mybatis-config.xml
<configuration><mappers><mapper resource="mapper/UserMapper.xml"/><mapper resource="mapper/ProductMapper.xml"/><mapper resource="mapper/CartItemMapper.xml"/><mapper resource="mapper/OrderMapper.xml"/><mapper resource="mapper/OrderDetailMapper.xml"/></mappers> </configuration>
- application.properties
实体类
User.java
package com.electronics.entity;public class User {private int id;private String username;private String password;private String email;private String phone;// Getters and Setters
}
Product.java
package com.electronics.entity;public class Product {private int id;private String name;private String description;private double price;private int stock;private String category;private String imageUrl;// Getters and Setters
}
CartItem.java
package com.electronics.entity;public class CartItem {private int id;private int userId;private int productId;private int quantity;// Getters and Setters
}
Order.java
package com.electronics.entity;import java.util.Date;public class Order {private int id;private int userId;private Date orderDate;private double totalPrice;private String status;// Getters and Setters
}
OrderDetail.java
package com.electronics.entity;public class OrderDetail {private int id;private int orderId;private int productId;private int quantity;private double price;// Getters and Setters
}
DAO 层
UserMapper.java
package com.electronics.mapper;import com.electronics.entity.User;
import org.apache.ibatis.annotations.*;@Mapper
public interface UserMapper {@Select("SELECT * FROM users WHERE username = #{username} AND password = #{password}")User login(@Param("username") String username, @Param("password") String password);@Insert("INSERT INTO users(username, password, email, phone) VALUES(#{username}, #{password}, #{email}, #{phone})")@Options(useGeneratedKeys = true, keyProperty = "id")void register(User user);
}
ProductMapper.java
package com.electronics.mapper;import com.electronics.entity.Product;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface ProductMapper {@Select("SELECT * FROM products")List<Product> getAllProducts();@Select("SELECT * FROM products WHERE id = #{id}")Product getProductById(int id);@Insert("INSERT INTO products(name, description, price, stock, category, image_url) VALUES(#{name}, #{description}, #{price}, #{stock}, #{category}, #{imageUrl})")@Options(useGeneratedKeys = true, keyProperty = "id")void addProduct(Product product);@Update("UPDATE products SET name=#{name}, description=#{description}, price=#{price}, stock=#{stock}, category=#{category}, image_url=#{imageUrl} WHERE id=#{id}")void updateProduct(Product product);@Delete("DELETE FROM products WHERE id=#{id}")void deleteProduct(int id);
}
CartItemMapper.java
package com.electronics.mapper;import com.electronics.entity.CartItem;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface CartItemMapper {@Select("SELECT * FROM cart_items WHERE user_id = #{userId}")List<CartItem> getCartItemsByUserId(int userId);@Insert("INSERT INTO cart_items(user_id, product_id, quantity) VALUES(#{userId}, #{productId}, #{quantity})")@Options(useGeneratedKeys = true, keyProperty = "id")void addToCart(CartItem cartItem);@Update("UPDATE cart_items SET quantity=#{quantity} WHERE id=#{id}")void updateCartItem(CartItem cartItem);@Delete("DELETE FROM cart_items WHERE id=#{id}")void deleteCartItem(int id);
}
OrderMapper.java
package com.electronics.mapper;import com.electronics.entity.Order;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface OrderMapper {@Select("SELECT * FROM orders WHERE user_id = #{userId}")List<Order> getOrdersByUserId(int userId);@Insert("INSERT INTO orders(user_id, order_date, total_price, status) VALUES(#{userId}, #{orderDate}, #{totalPrice}, #{status})")@Options(useGeneratedKeys = true, keyProperty = "id")void addOrder(Order order);@Update("UPDATE orders SET order_date=#{orderDate}, total_price=#{totalPrice}, status=#{status} WHERE id=#{id}")void updateOrder(Order order);@Delete("DELETE FROM orders WHERE id=#{id}")void deleteOrder(int id);
}
OrderDetailMapper.java
package com.electronics.mapper;import com.electronics.entity.OrderDetail;
import org.apache.ibatis.annotations.*;import java.util.List;@Mapper
public interface OrderDetailMapper {@Select("SELECT * FROM order_details WHERE order_id = #{orderId}")List<OrderDetail> getOrderDetailsByOrderId(int orderId);@Insert("INSERT INTO order_details(order_id, product_id, quantity, price) VALUES(#{orderId}, #{productId}, #{quantity}, #{price})")@Options(useGeneratedKeys = true, keyProperty = "id")void addOrderDetail(OrderDetail orderDetail);
}
Service 层
UserService.java
package com.electronics.service;import com.electronics.entity.User;
import com.electronics.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;@Service
public class UserService {@Autowiredprivate UserMapper userMapper;public User login(String username, String password) {return userMapper.login(username, password);}public void register(User user) {userMapper.register(user);}
}
ProductService.java
package com.electronics.service;import com.electronics.entity.Product;
import com.electronics.mapper.ProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class ProductService {@Autowiredprivate ProductMapper productMapper;public List<Product> getAllProducts() {return productMapper.getAllProducts();}public Product getProductById(int id) {return productMapper.getProductById(id);}public void addProduct(Product product) {productMapper.addProduct(product);}public void updateProduct(Product product) {productMapper.updateProduct(product);}public void deleteProduct(int id) {productMapper.deleteProduct(id);}
}
CartService.java
package com.electronics.service;import com.electronics.entity.CartItem;
import com.electronics.mapper.CartItemMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class CartService {@Autowiredprivate CartItemMapper cartItemMapper;public List<CartItem> getCartItemsByUserId(int userId) {return cartItemMapper.getCartItemsByUserId(userId);}public void addToCart(CartItem cartItem) {cartItemMapper.addToCart(cartItem);}public void updateCartItem(CartItem cartItem) {cartItemMapper.updateCartItem(cartItem);}public void deleteCartItem(int id) {cartItemMapper.deleteCartItem(id);}
}
OrderService.java
package com.electronics.service;import com.electronics.entity.Order;
import com.electronics.entity.OrderDetail;
import com.electronics.mapper.OrderDetailMapper;
import com.electronics.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class OrderService {@Autowiredprivate OrderMapper orderMapper;@Autowiredprivate OrderDetailMapper orderDetailMapper;public List<Order> getOrdersByUserId(int userId) {return orderMapper.getOrdersByUserId(userId);}public void addOrder(Order order) {orderMapper.addOrder(order);for (OrderDetail detail : order.getOrderDetails()) {orderDetailMapper.addOrderDetail(detail);}}public void updateOrder(Order order) {orderMapper.updateOrder(order);}public void deleteOrder(int id) {orderMapper.deleteOrder(id);}
}
Controller 层
UserController.java
package com.electronics.controller;import com.electronics.entity.User;
import com.electronics.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;@Controller
public class UserController {@Autowiredprivate UserService userService;@GetMapping("/login")public String showLoginForm() {return "login";}@PostMapping("/login")public String handleLogin(@RequestParam("username") String username, @RequestParam("password") String password, Model model) {User user = userService.login(username, password);if (user != null) {model.addAttribute("user", user);return "redirect:/products";} else {model.addAttribute("error", "Invalid username or password");return "login";}}@GetMapping("/register")public String showRegisterForm() {return "register";}@PostMapping("/register")public String handleRegister(User user) {userService.register(user);return "redirect:/login";}
}
ProductController.java
package com.electronics.controller;import com.electronics.entity.Product;
import com.electronics.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;import java.util.List;@Controller
public class ProductController {@Autowiredprivate ProductService productService;@GetMapping("/products")public String showProducts(Model model) {List<Product> products = productService.getAllProducts();model.addAttribute("products", products);return "products";}@GetMapping("/product/{id}")public String showProductDetails(@RequestParam("id") int id, Model model) {Product product = productService.getProductById(id);model.addAttribute("product", product);return "productDetails";}@GetMapping("/addProduct")public String showAddProductForm() {return "addProduct";}@PostMapping("/addProduct")public String handleAddProduct(Product product) {productService.addProduct(product);return "redirect:/products";}@GetMapping("/editProduct/{id}")public String showEditProductForm(@RequestParam("id") int id, Model model) {Product product = productService.getProductById(id);model.addAttribute("product", product);return "editProduct";}@PostMapping("/editProduct")public String handleEditProduct(Product product) {productService.updateProduct(product);return "redirect:/products";}@GetMapping("/deleteProduct/{id}")public String handleDeleteProduct(@RequestParam("id") int id) {productService.deleteProduct(id);return "redirect:/products";}
}
CartController.java
package com.electronics.controller;import com.electronics.entity.CartItem;
import com.electronics.entity.Product;
import com.electronics.service.CartService;
import com.electronics.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;import java.util.List;@Controller
public class CartController {@Autowiredprivate CartService cartService;@Autowiredprivate ProductService productService;@GetMapping("/cart")public String showCart(@RequestParam("userId") int userId, Model model) {List<CartItem> cartItems = cartService.getCartItemsByUserId(userId);model.addAttribute("cartItems", cartItems);return "cart";}@PostMapping("/addToCart")public String handleAddToCart(@RequestParam("userId") int userId, @RequestParam("productId") int productId, @RequestParam("quantity") int quantity) {Product product = productService.getProductById(productId);CartItem cartItem = new CartItem();cartItem.setUserId(userId);cartItem.setProductId(productId);cartItem.setQuantity(quantity);cartService.addToCart(cartItem);return "redirect:/cart?userId=" + userId;}@PostMapping("/updateCartItem")public String handleUpdateCartItem(@RequestParam("id") int id, @RequestParam("quantity") int quantity) {CartItem cartItem = new CartItem();cartItem.setId(id);cartItem.setQuantity(quantity);cartService.updateCartItem(cartItem);return "redirect:/cart?userId=" + cartItem.getUserId();}@GetMapping("/removeFromCart/{id}")public String handleRemoveFromCart(@RequestParam("id") int id, @RequestParam("userId") int userId) {cartService.deleteCartItem(id);return "redirect:/cart?userId=" + userId;}
}
OrderController.java
package com.electronics.controller;import com.electronics.entity.Order;
import com.electronics.entity.OrderDetail;
import com.electronics.entity.Product;
import com.electronics.service.OrderService;
import com.electronics.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;import java.util.ArrayList;
import java.util.Date;
import java.util.List;@Controller
public class OrderController {@Autowiredprivate OrderService orderService;@Autowiredprivate ProductService productService;@GetMapping("/orders")public String showOrders(@RequestParam("userId") int userId, Model model) {List<Order> orders = orderService.getOrdersByUserId(userId);model.addAttribute("orders", orders);return "orders";}@PostMapping("/placeOrder")public String handlePlaceOrder(@RequestParam("userId") int userId, @RequestParam("cartItemIds") String cartItemIds) {Order order = new Order();order.setUserId(userId);order.setOrderDate(new Date());order.setTotalPrice(0.0);order.setStatus("Pending");List<OrderDetail> orderDetails = new ArrayList<>();String[] ids = cartItemIds.split(",");for (String id : ids) {int cartItemId = Integer.parseInt(id);CartItem cartItem = cartService.getCartItemById(cartItemId);Product product = productService.getProductById(cartItem.getProductId());OrderDetail orderDetail = new OrderDetail();orderDetail.setProductId(cartItem.getProductId());orderDetail.setQuantity(cartItem.getQuantity());orderDetail.setPrice(product.getPrice());orderDetails.add(orderDetail);order.setTotalPrice(order.getTotalPrice() + product.getPrice() * cartItem.getQuantity());}order.setOrderDetails(orderDetails);orderService.addOrder(order);// 清空购物车for (OrderDetail detail : orderDetails) {cartService.deleteCartItem(detail.getId());}return "redirect:/orders?userId=" + userId;}
}
前端页面
使用 JSP 创建前端页面。以下是简单的 JSP 示例:
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Login</title>
</head>
<body>
<h2>Login</h2>
<form action="${pageContext.request.contextPath}/login" method="post">Username: <input type="text" name="username"><br>Password: <input type="password" name="password"><br><input type="submit" value="Login">
</form>
<c:if test="${not empty error}"><p style="color: red">${error}</p>
</c:if>
</body>
</html>
products.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head><title>Products</title>
</head>
<body>
<h2>Products</h2>
<table><tr><th>Name</th><th>Description</th><th>Price</th><th>Stock</th><th>Category</th><th>Action</th></tr><c:forEach items="${products}" var="product"><tr><td>${product.name}</td><td>${product.description}</td><td>${product.price}</td><td>${product.stock}</td><td>${product.category}</td><td><a href="${pageContext.request.contextPath}/product/${product.id}">View</a><a href="${pageContext.request.contextPath}/addToCart?userId=${user.id}&productId=${product.id}&quantity=1">Add to Cart</a></td></tr></c:forEach>
</table>
<a href="${pageContext.request.contextPath}/addProduct">Add New Product</a>
</body>
</html>
cart.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head><title>Cart</title>
</head>
<body>
<h2>Cart</h2>
<table><tr><th>Product Name</th><th>Quantity</th><th>Price</th><th>Action</th></tr><c:forEach items="${cartItems}" var="cartItem"><tr><td>${cartItem.product.name}</td><td>${cartItem.quantity}</td><td>${cartItem.product.price}</td><td><a href="${pageContext.request.contextPath}/removeFromCart?id=${cartItem.id}&userId=${user.id}">Remove</a></td></tr></c:forEach>
</table>
<a href="${pageContext.request.contextPath}/placeOrder?userId=${user.id}&cartItemIds=${cartItemIds}">Place Order</a>
</body>
</html>
测试与调试
对每个功能进行详细测试,确保所有功能都能正常工作。
部署与发布
编译最终版本的应用程序,并准备好 WAR 文件供 Tomcat 或其他应用服务器部署。
相关文章:
基于 SSM(Spring + Spring MVC + MyBatis)框架构建电器网上订购系统
基于 SSM(Spring Spring MVC MyBatis)框架构建电器网上订购系统可以为用户提供一个方便快捷的购物平台。以下将详细介绍该系统的开发流程,包括需求分析、技术选型、数据库设计、项目结构搭建、主要功能实现以及前端页面设计。 需求分析 …...
应用插件化及其进程关系梳理
插件应用的AndroidManifest.xml <manifest xmlns:android"http://schemas.android.com/apk/res/android"coreApp"true"package"com.demo.phone"android:sharedUserId"android.uid.phone"><uses-sdk android:minSdkVersion&q…...
Odoo:免费开源的医药流通行业信息化解决方案
文 / 开源智造Odoo亚太金牌服务 方案概述 开源智造Odoo免费开源ERP提供面向医药批发采、供、销业财一体化,及直接面向消费者的门店终端、全渠道管理、营销管理以及GSP合规管理解决方案,提升企业运营效率和全业务链条的数字化管控、追溯能力。 行业的最新…...
系统架构设计师论文:大数据Lambda架构
论文一:大数据Lambda架构 1简要说明你参与开发的软件项目,以及你所承担的主要工作 2 lamada体系架构将数据流分为批处理层(Batch Layer)、加速层(Speed Layer)、服务层(Serving Layer)。简要叙述这三个层次的用途和特点 3 详细阐述你参与开发的软件项目是如何基于lamada…...
亚信安全新一代WAF:抵御勒索攻击的坚固防线
近年来,勒索攻击已成为黑客的主要攻击手段。新型勒索攻击事件层出不穷,勒索攻击形势愈发严峻,已经对全球制造、金融、能源、医疗、政府组织等关键领域造成严重危害。如今,勒索攻击手段日趋成熟、攻击目标愈发明确,模式…...
Flutter 中的那些设计模式的写法(持续更新)
前言 我们都知道设计模式是相同的,同一种设计模式的理念不会因为语言不同而会有所改变,但是由于语法的差异,设计模式的写法也有所差异,本文会介绍一些flutter中常用设计模式的写法以及使用场景。 常见的设计模式有23种࿰…...
【提效工具开发】Python功能模块执行和 SQL 执行 需求整理
需求梳理 背景 当前我们在IDE或MySQL查询工具中只能进行个人使用,缺乏共享功能,且在查询及数据统计上有一定的不便。为了改善这种情况,计划搭建一个Web平台,通过后台交互来提升效率。此平台需要兼容Python工具和SQL工具的管理、执…...
Linux系列-进程的状态
🌈个人主页:羽晨同学 💫个人格言:“成为自己未来的主人~” 操作系统就是计算机领域的哲学,是为了保证在所有情况下都适用,加载到内存叫做新建状态。 并行和并发 计算机同时进行多个任务,在用户感知的…...
SpringBoot项目中常用的一些注解
一、核心注解 SpringBootApplication 作用:标注一个主程序类,表明这是一个Spring Boot应用程序的入口。说明:这是一个复合注解,组合了Configuration、EnableAutoConfiguration和ComponentScan。 EnableAutoConfiguration 作用&…...
【网络】自定义协议——序列化和反序列化
> 作者:დ旧言~ > 座右铭:松树千年终是朽,槿花一日自为荣。 > 目标:了解什么是序列化和分序列,并且自己能手撕网络版的计算器。 > 毒鸡汤:有些事情,总是不明白,所以我不…...
Pytorch如何精准记录函数运行时间
0. 引言 参考Pytorch官方文档对CUDA的描述,GPU的运算是异步执行的。一般来说,异步计算的效果对于调用者来说是不可见的,因为 每个设备按照排队的顺序执行操作Pytorch对于CPU和GPU的同步,GPU间的同步是自动执行的,不需…...
使用 Java 实现邮件发送功能
引言 1. JavaMail API 简介 2. 环境准备 2.1 Maven 依赖 2.2 Gradle 依赖 3. 发送简单文本邮件 4. 发送 HTML 邮件 5. 发送带附件的邮件 6. 注意事项 引言 在现代应用开发中,邮件发送功能是非常常见的需求,例如用户注册验证、密码重置、订单确认…...
html第一个网页
创建你的第一个HTML网页是一个激动人心的步骤。以下是创建一个简单网页的基本步骤和代码示例: 基础结构:所有的HTML文档都应该包含以下基本结构。 <!DOCTYPE html> <html> <head><title>我的第一个网页</title> </he…...
前后端交互接口(三)
前后端交互接口(三) 前言 前两集我们先做了前后端交互接口的约定以及浅浅的阅读了一些proto代码。那么这一集我们就来看看一些重要的proto代码,之后把protobuffer给引入我们的项目当中! gateway.proto 我们来看一眼我们的网关…...
华为Mate70前瞻,鸿蒙NEXT正式版蓄势待发,国产系统迎来关键一战
Mate 70系列要来了 上个月,vivo、小米、OPPO、荣耀等众多智能手机制造商纷纷发布了他们的年度旗舰产品,手机行业内竞争异常激烈。 同时,华为首席执行官余承东在其个人微博上透露,Mate 70系列将标志着华为Mate系列手机达到前所未有…...
【安卓13 源码】Input子系统(4)- InputReader 数据处理
1. 多指触控协议 多指触控协议有 2 种: > A类: 处理无关联的接触: 用于直接发送原始数据; > B类: 处理跟踪识别类的接触: 通过事件slot发送相关联的独立接触更新。 B协议可以使用一个ID来标识触点&…...
Xserver v1.4.2发布,支持自动重载 nginx 配置
Xserver——优雅、强大的 php 集成开发环境 本次更新为大家带来了更好的用户体验。 🎉 下载依赖组件时,显示进度条,展示下载进度。 🎉 保存站点信息和手动修改 vhost 配置文件之后,自动重载 nginx 配置 🐞…...
Java反射原理及其性能优化
目录 JVM是如何实现反射的反射的性能开销体现在哪里如何优化反射性能开销 1. JVM是如何实现反射的? 反射是Java语言中的一种强大功能,它允许程序在运行时动态地获取类的信息以及操作对象。下面是一个简单的示例,演示了如何使用反射调用方法ÿ…...
RabbitMQ 管理平台(控制中心)的介绍
文章目录 一、RabbitMQ 管理平台整体介绍二、Overview 总览三、Connections 连接四、Channels 通道五、Exchanges 交换机六、Queues 队列查看队列详细信息查看队列的消息内容 七、Admin 用户给用户分配虚拟主机 一、RabbitMQ 管理平台整体介绍 RabbitMQ 管理平台内有六个模块&…...
【SQL】在 SQL Server 中创建数据源是 MySQL 数据表的视图
背景:Windows系统已安装了mysql5.7和sqlServer数据库,现在需要在sqlServer创建视图或者查询来自mysql的数据,视图的数据来源mysql数据库。下面进行实现在sqlserver实现获取mysql数据表数据构建视图。 1、打开 ODBC 数据源管理器,…...
C++实现分布式网络通信框架RPC(3)--rpc调用端
目录 一、前言 二、UserServiceRpc_Stub 三、 CallMethod方法的重写 头文件 实现 四、rpc调用端的调用 实现 五、 google::protobuf::RpcController *controller 头文件 实现 六、总结 一、前言 在前边的文章中,我们已经大致实现了rpc服务端的各项功能代…...
Prompt Tuning、P-Tuning、Prefix Tuning的区别
一、Prompt Tuning、P-Tuning、Prefix Tuning的区别 1. Prompt Tuning(提示调优) 核心思想:固定预训练模型参数,仅学习额外的连续提示向量(通常是嵌入层的一部分)。实现方式:在输入文本前添加可训练的连续向量(软提示),模型只更新这些提示参数。优势:参数量少(仅提…...
.Net框架,除了EF还有很多很多......
文章目录 1. 引言2. Dapper2.1 概述与设计原理2.2 核心功能与代码示例基本查询多映射查询存储过程调用 2.3 性能优化原理2.4 适用场景 3. NHibernate3.1 概述与架构设计3.2 映射配置示例Fluent映射XML映射 3.3 查询示例HQL查询Criteria APILINQ提供程序 3.4 高级特性3.5 适用场…...
根据万维钢·精英日课6的内容,使用AI(2025)可以参考以下方法:
根据万维钢精英日课6的内容,使用AI(2025)可以参考以下方法: 四个洞见 模型已经比人聪明:以ChatGPT o3为代表的AI非常强大,能运用高级理论解释道理、引用最新学术论文,生成对顶尖科学家都有用的…...
C++八股 —— 单例模式
文章目录 1. 基本概念2. 设计要点3. 实现方式4. 详解懒汉模式 1. 基本概念 线程安全(Thread Safety) 线程安全是指在多线程环境下,某个函数、类或代码片段能够被多个线程同时调用时,仍能保证数据的一致性和逻辑的正确性…...
Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决
Spring Cloud Gateway 中自定义验证码接口返回 404 的排查与解决 问题背景 在一个基于 Spring Cloud Gateway WebFlux 构建的微服务项目中,新增了一个本地验证码接口 /code,使用函数式路由(RouterFunction)和 Hutool 的 Circle…...
九天毕昇深度学习平台 | 如何安装库?
pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子: 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...
蓝桥杯 冶炼金属
原题目链接 🔧 冶炼金属转换率推测题解 📜 原题描述 小蓝有一个神奇的炉子用于将普通金属 O O O 冶炼成为一种特殊金属 X X X。这个炉子有一个属性叫转换率 V V V,是一个正整数,表示每 V V V 个普通金属 O O O 可以冶炼出 …...
return this;返回的是谁
一个审批系统的示例来演示责任链模式的实现。假设公司需要处理不同金额的采购申请,不同级别的经理有不同的审批权限: // 抽象处理者:审批者 abstract class Approver {protected Approver successor; // 下一个处理者// 设置下一个处理者pub…...
A2A JS SDK 完整教程:快速入门指南
目录 什么是 A2A JS SDK?A2A JS 安装与设置A2A JS 核心概念创建你的第一个 A2A JS 代理A2A JS 服务端开发A2A JS 客户端使用A2A JS 高级特性A2A JS 最佳实践A2A JS 故障排除 什么是 A2A JS SDK? A2A JS SDK 是一个专为 JavaScript/TypeScript 开发者设计的强大库ÿ…...
