Spring框架的事务管理

引言

在企业级应用开发中,事务管理是一个至关重要的环节,它确保了数据的一致性和完整性。Spring 框架为我们提供了强大而灵活的事务管理功能,能够帮助开发者更轻松地处理复杂的事务场景。本文将深入探讨 Spring 框架的事务管理,包括相关的类和 API,以及声明式事务管理的实现方式,并结合具体代码示例进行详细解释。

1. Spring 框架的事务管理相关的类和 API

1.1 PlatformTransactionManager 接口

PlatformTransactionManager 是 Spring 框架中用于管理事务的核心接口,它定义了事务的基本操作,如提交和回滚。该接口有具体的实现类,我们需要根据不同的持久层框架选择合适的实现类。

接口方法
  • void commit(TransactionStatus status):用于提交事务。
  • void rollback(TransactionStatus status):用于回滚事务。
实现类选择
  • DataSourceTransactionManager:如果使用 Spring 的 JDBC 模板或者 MyBatis 框架,应选择这个实现类。因为这些框架都是基于数据源(DataSource)进行数据库操作的,DataSourceTransactionManager 可以很好地与数据源集成,管理事务。
  • HibernateTransactionManager:当使用 Hibernate 框架时,需要选择这个实现类。它专门为 Hibernate 的事务管理而设计,能够与 Hibernate 的会话(Session)和事务机制无缝对接。

1.2 TransactionDefinition 接口

TransactionDefinition 接口定义了事务的一些基本属性,包括事务隔离级别和事务传播行为。

事务隔离级别

事务隔离级别用于控制多个事务之间的可见性和并发访问。常见的隔离级别有:

  • ISOLATION_DEFAULT:使用数据库的默认隔离级别。
  • ISOLATION_READ_UNCOMMITTED:允许读取未提交的数据,可能会导致脏读、不可重复读和幻读问题。
  • ISOLATION_READ_COMMITTED:只能读取已提交的数据,避免了脏读,但仍可能出现不可重复读和幻读。
  • ISOLATION_REPEATABLE_READ:保证在同一个事务中多次读取同一数据的结果是一致的,避免了脏读和不可重复读,但仍可能出现幻读。
  • ISOLATION_SERIALIZABLE:最高的隔离级别,所有事务依次执行,避免了脏读、不可重复读和幻读,但会降低并发性能。

事务传播行为

事务传播行为定义了在一个事务方法调用另一个事务方法时,事务应该如何处理。常见的传播行为有:

  • PROPAGATION_REQUIRED:如果当前存在事务,则加入该事务;如果不存在,则创建一个新的事务。
  • PROPAGATION_SUPPORTS:如果当前存在事务,则加入该事务;如果不存在,则以非事务方式执行。
  • PROPAGATION_MANDATORY:如果当前存在事务,则加入该事务;如果不存在,则抛出异常。
  • PROPAGATION_REQUIRES_NEW:无论当前是否存在事务,都创建一个新的事务,并挂起当前事务。
  • PROPAGATION_NOT_SUPPORTED:以非事务方式执行,如果当前存在事务,则挂起该事务。
  • PROPAGATION_NEVER:以非事务方式执行,如果当前存在事务,则抛出异常。
  • PROPAGATION_NESTED:如果当前存在事务,则在嵌套事务中执行;如果不存在,则创建一个新的事务。

 2. Spring 框架声明式事务管理

2.1、XML 配置方式

1. 配置文件

  • jdbc.properties:存储数据库连接信息,包括驱动类名、URL、用户名和密码。
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_db?useSSL=false&characterEncoding=utf8
jdbc.username=root
jdbc.password=root
  • applicationContext.xml:核心配置文件,主要完成以下配置:
    • 加载属性文件:通过 <context:property - placeholder> 加载 jdbc.properties
    • 配置数据源:使用 Druid 数据源,将属性文件中的配置注入。
    • 配置平台事务管理器:使用 DataSourceTransactionManager,并关联数据源。
    • 配置事务通知:通过 <tx:advice> 定义事务属性,如 pay 方法使用事务,find* 方法只读。
    • 配置 AOP:通过 <aop:config> 定义切入点和通知的关联。
    • 配置 Service 和 Dao:将 Service 和 Dao 作为 Bean 注册到 Spring 容器中,并进行依赖注入。
<?xml version="1.0" encoding="UTF-8"?>
<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:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"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/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd"><!-- 加载属性文件 --><context:property-placeholder location="classpath:jdbc.properties"/><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="driverClassName" value="${jdbc.driverClassName}"/><property name="url" value="${jdbc.url}"/><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/></bean><!-- 配置平台事务管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 配置事务通知 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><!-- pay 方法使用事务 --><tx:method name="pay" isolation="DEFAULT" propagation="REQUIRED"/><!-- find 开头的方法只读 --><tx:method name="find*" read-only="true"/></tx:attributes></tx:advice><!-- 配置 AOP --><aop:config><aop:advisor advice-ref="txAdvice" pointcut="execution(public * com.qcbyjy.demo4.AccountServiceImpl.pay(..))"/></aop:config><!-- 配置 Service --><bean id="accountService" class="com.qcbyjy.demo1.AccountServiceImpl"><property name="accountDao" ref="accountDao"/></bean><!-- 配置 Dao --><bean id="accountDao" class="com.qcbyjy.demo1.AccountDaoImpl"><property name="dataSource" ref="dataSource"/></bean>
</beans>

2.Java类 

  • AccountDao.java:定义数据访问接口,包含 outMoneyinMoney 和 findMoney 方法。
package com.qcbyjy.demo1;public interface AccountDao {void outMoney(String out, double money);void inMoney(String in, double money);double findMoney(String name);
}
  • AccountDaoImpl.java:实现 AccountDao 接口,通过 JdbcDaoSupport 进行数据库操作。
package com.qcbyjy.demo1;import org.springframework.jdbc.core.support.JdbcDaoSupport;public class AccountDaoImpl extends JdbcDaoSupport implements AccountDao {@Overridepublic void outMoney(String out, double money) {String sql = "update account set money=money-? where name=?";this.getJdbcTemplate().update(sql, money, out);}@Overridepublic void inMoney(String in, double money) {String sql = "update account set money=money+? where name=?";this.getJdbcTemplate().update(sql, money, in);}@Overridepublic double findMoney(String name) {String sql = "select money from account where name=?";return this.getJdbcTemplate().queryForObject(sql, Double.class, name);}
}
  • AccountService.java:定义业务服务接口,包含 pay 和 checkBalance 方法。
package com.qcbyjy.demo1;public interface AccountService {void pay(String out, String in, double money);double checkBalance(String name);
}
  • AccountServiceImpl.java:实现 AccountService 接口,调用 AccountDao 完成业务逻辑。
package com.qcbyjy.demo1;public class AccountServiceImpl implements AccountService {private AccountDao accountDao;public void setAccountDao(AccountDao accountDao) {this.accountDao = accountDao;}@Overridepublic void pay(String out, String in, double money) {accountDao.outMoney(out, money);// 模拟异常,测试事务回滚// int a = 1/0;accountDao.inMoney(in, money);}@Overridepublic double checkBalance(String name) {return accountDao.findMoney(name);}
}

3.测试 

package com.qcbyjy.test.demo1;import com.qcbyjy.demo1.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo1 {@Testpublic void testXmlTransaction(){ApplicationContext context =new ClassPathXmlApplicationContext("applicationContext.xml");AccountService accountService =(AccountService) context.getBean("accountService");System.out.println("XML配置方式事务测试...");try {accountService.pay("aaa", "ccc", 100);System.out.println("转账成功!");} catch (Exception e) {System.out.println("转账失败,事务已回滚:" + e.getMessage());}}
}

4. 重要知识点

  • 事务通知和 AOP 配置:通过 <tx:advice> 定义事务属性,再通过 <aop:config> 将事务通知应用到指定的切入点,实现事务的织入。
  • 属性占位符<context:property - placeholder> 可以方便地加载属性文件,将配置信息从 XML 文件中分离出来,提高配置的可维护性。

2.2、XML + 注解方式

1. 配置文件

  • applicationContext_1.xml:主要完成以下配置:
    • 开启注解扫描:通过 <context:component - scan> 扫描指定包下的注解组件。
    • 加载属性文件:同 XML 配置方式。
    • 配置数据源和事务管理器:同 XML 配置方式。
    • 配置 Jdbc 模板:为 Dao 层提供数据库操作模板。
    • 开启事务注解支持:通过 <tx:annotation - driven> 开启 @Transactional 注解的支持。
<?xml version="1.0" encoding="UTF-8"?>
<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:tx="http://www.springframework.org/schema/tx"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/txhttp://www.springframework.org/schema/tx/spring-tx.xsd"><!-- 开启注解扫描 --><context:component-scan base-package="com.qcbyjy.demo2"/><!-- 加载属性文件 --><context:property-placeholder location="classpath:db.properties"/><!-- 配置数据源 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="driverClassName" value="${jdbc.driverClassName}"/><property name="url" value="${jdbc.url}"/><property name="username" value="${jdbc.username}"/><property name="password" value="${jdbc.password}"/></bean><!-- 配置平台事务管理器 --><bean id="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"/></bean><!-- 配置Jdbc模板 --><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource" ref="dataSource"/></bean><!-- 开启事务注解支持 --><tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

2. Java 类

  • AccountDao.java:同 XML 配置方式。
  • AccountDaoImpl.java:使用 @Repository 注解将该类注册为 Spring Bean,并通过 @Autowired 注入 JdbcTemplate
package com.qcbyjy.demo2;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;@Repository
public class AccountDaoImpl  implements AccountDao {@Autowiredprivate JdbcTemplate jdbcTemplate;/***付款*@paramout*@parammoney*/public void outMoney(String out,double money){String sql="update account set money=money - ? where name = ?";jdbcTemplate.update(sql,money,out);}/***收款*@paramin*@parammoney*/public void inMoney(String in,double money){String sql="update account set money=money +? where name= ?";jdbcTemplate.update(sql,money,in);}}
  • AccountService.java:同 XML 配置方式。
  • AccountServiceImpl.java:使用 @Service 注解将该类注册为 Spring Bean,并使用 @Transactional 注解定义事务属性。
package com.qcbyjy.demo2;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;@Service
@Transactional(isolation = Isolation.DEFAULT)
public class AccountServiceImpl implements AccountService {@Autowiredprivate AccountDao accountDao;/***转账方法*@paramout付款人*@paramin收款人*@parammoney金额*/public void pay(String out,String in,double money){accountDao.outMoney(out,money);// 模拟异常
//         int a = 1/0;accountDao.inMoney(in,money);}}

3.测试

package com.qcbyjy.test.demo2;import com.qcbyjy.demo2.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo2 {@Testpublic void testAnnotationTransaction(){ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext_1.xml");AccountService accountService=context.getBean(AccountService.class);System.out.println("XML+注解方式事务测试...");try {accountService.pay("ccc", "aaa", 100);System.out.println("转账成功!");} catch (Exception e) {System.out.println("转账失败,事务已回滚:" + e.getMessage());}}
}

4. 重要知识点

  • 注解扫描<context:component - scan> 可以自动扫描指定包下的 @Component@Repository@Service 和 @Controller 注解的类,并将它们注册为 Spring Bean。
  • @Transactional 注解:用于定义事务属性,如隔离级别、传播行为、是否只读等。可以应用在类或方法上,应用在类上时,该类的所有公共方法都将应用该事务属性。

 2.3、纯注解方式

1. Java 配置类

  • SpringConfig.java:使用 @Configuration 注解将该类标记为配置类,通过 @ComponentScan 扫描指定包下的注解组件,使用 @EnableTransactionManagement 开启事务注解支持,并通过 @Bean 方法定义数据源、Jdbc 模板和事务管理器。
package com.qcbyjy.demo3;import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;import javax.annotation.Resource;
import javax.sql.DataSource;@Configuration
@ComponentScan(basePackages = "com.qcbyjy.demo3")
@EnableTransactionManagement
public class SpringConfig {@Bean(name="dataSource")public DataSource dataSource() {// 创建连接池对象,Spring框架内置了连接池对象DruidDataSource dataSource = new DruidDataSource();// 设置4个参数dataSource.setDriverClassName("com.mysql.jdbc.Driver");dataSource.setUrl("jdbc:mysql://localhost:3306/spring_db?useSSL=false&characterEncoding=utf8");dataSource.setUsername("root");dataSource.setPassword("12345");return dataSource;}@Resource(name="dataSource")@Bean(name="jdbcTemplate")public JdbcTemplate createJdbcTemplate(DataSource dataSource){JdbcTemplate template =new JdbcTemplate(dataSource);return template;}@Resource(name="dataSource")@Bean(name="transactionManager")public PlatformTransactionManager createTransactionManager(DataSource dataSource) {DataSourceTransactionManager manager = new DataSourceTransactionManager(dataSource);return manager;}//    @Bean
//    public JdbcTemplate jdbcTemplate(DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }//    @Bean
//    public PlatformTransactionManager transactionManager(DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
}

2. Java 类

  • AccountDao.javaAccountDaoImpl.javaAccountService.java 和 AccountServiceImpl.java:同 XML + 注解方式。

3.测试

package com.qcbyjy.test.Demo3;import com.qcbyjy.demo3.AccountService;
import com.qcbyjy.demo3.SpringConfig;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;public class Demo3 {@Testpublic void testPureAnnotationTransaction() {AnnotationConfigApplicationContext context=new AnnotationConfigApplicationContext(SpringConfig.class);AccountService accountService=context.getBean(AccountService.class);System.out.println("纯注解方式事务测试...");try {accountService.pay("aaa", "ccc", 1000);System.out.println("转账成功!");} catch (Exception e) {System.out.println("转账失败,事务已回滚:" + e.getMessage());}context.close();}
}

4. 重要知识点

  • Java 配置类:使用 @Configuration 注解的类可以替代 XML 配置文件,通过 @Bean 方法定义 Bean,提高配置的灵活性和可维护性。
  • @EnableTransactionManagement:开启 Spring 的事务注解支持,使得 @Transactional 注解生效。

4.事务特性验证

三种方式都可以通过取消注释模拟异常的代码(int a = 1/0;)来测试事务回滚功能。每次测试前后会打印账户余额,验证事务是否正常工作。同时,需要创建 spring_db 数据库和 account 表,并初始化张三和李四的账户余额为 1000。

5.总结

  • XML 配置方式:适合于对配置细节有严格要求,且团队对 XML 配置比较熟悉的场景。通过 XML 可以清晰地定义事务的各个方面,但配置文件可能会变得冗长和复杂。
  • XML + 注解方式:结合了 XML 配置的灵活性和注解的简洁性,XML 负责全局配置,注解负责局部配置,是一种比较常用的方式。
  • 纯注解方式:适合于追求代码简洁性和开发效率的场景,完全基于 Java 配置和注解,减少了 XML 配置文件的使用,但对开发者的 Java 配置能力要求较高。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/80940.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

FPGA: UltraScale+ bitslip实现(ISERDESE3)

收获 一晃五年~ 五年前那个夏夜&#xff0c;我对着泛蓝的屏幕敲下《给十年后的自己》&#xff0c;在2020年的疫情迷雾中编织着对未来的想象。此刻回望&#xff0c;第四届集创赛的参赛编号仍清晰如昨&#xff0c;而那个在家熬夜焊电路板的"不眠者"&#xff0c;现在…

用 wireshark 解密 SIP over TLS 以及 SRTP 解密

--todo 有空再搞 MicroSIP 向 FreeSWITCH 注册&#xff0c;transport 设置为 tls 同时 Media Encryption 设置为强制 FreeSWITCH 做一个这样的路由&#xff1a; <action application"set" data"rtp_secure_mediaoptional"/> <action applicat…

Delphi 12.3调用Chrome/edge内核实现DEMO源码

DELPHI使用调用Chrome/Edge内核浏览器&#xff0c;虽然旧的WebBrowser也还可以用&#xff0c;但大势所趋&#xff0c;新版的已经不需要使用第三方的组件了&#xff0c;算是全内置的开发了&#xff0c;不废话 Unit1 源码 Form 源码 unit Unit1;interfaceusesWinapi.Windows, W…

快速搭建一个electron-vite项目

1. 初始化项目 在命令行中运行以下命令 npm create quick-start/electronlatest也可以通过附加命令行选项直接指定项目名称和你想要使用的模版。例如&#xff0c;要构建一个 Electron Vue 项目&#xff0c;运行: # npm 7&#xff0c;需要添加额外的 --&#xff1a; npm cre…

26考研 | 王道 | 计算机组成原理 | 一、计算机系统概述

26考研 | 王道 | 计算机组成原理 | 一、计算机系统概述 文章目录 26考研 | 王道 | 计算机组成原理 | 一、计算机系统概述1.1 计算机的发展1.2 计算机硬件和软件1.2.1 计算机硬件的基本组成1.2.2 各个硬件的工作原理1.2.3 计算机软件1.2.4 计算机系统的层次结构1.2.5 计算机系统…

01-数据结构概述和时间空间复杂度

数据结构概述和时间空间复杂度 1. 什么是数据结构 数据结构&#xff08;Data Structure&#xff09;是计算机存储、组织数据的方式&#xff0c;指相互之间存在一种或多种特定关系的数据元素的集合。 2. 什么是算法 算法&#xff08;Algorithm&#xff09;就是定义良好的计算…

大数据架构选型全景指南:核心架构对比与实战案例 解析

目录 大数据架构选型全景指南&#xff1a;核心架构对比与实战案例解析1. 主流架构全景概览1.1 核心架构类型1.2 关键选型维度 2. 架构对比与选型矩阵2.1 主流架构对比表2.2 选型决策树 3. 案例分析与实现案例1&#xff1a;电商实时推荐系统&#xff08;Lambda架构&#xff09;案…

(51单片机)LCD显示红外遥控相关数字(Delay延时函数)(LCD1602教程)(Int0和Timer0外部中断教程)(IR红外遥控模块教程)

前言&#xff1a; 本次Timer0模块改装了一下&#xff0c;注意&#xff01;&#xff01;&#xff01;今天只是简单的实现一下&#xff0c;明天用次功能显示遥控密码锁 演示视频&#xff1a; 在审核 源代码&#xff1a; 如上图将9个文放在Keli5 中即可&#xff0c;然后烧录在…

网络实验-防火墙双机热备份

实验目的 了解防火墙双机热备份配置&#xff0c;提供部署防火墙可靠性。 网络拓扑 左侧为trust域&#xff0c;右侧为untrust域。防火墙之间配置双机热备份。 配置内容 master VRRP 由于防火墙是基于会话表匹配回程流量&#xff0c;流量去向和回程必须通过同一个防火墙。…

【2025最新】VSCode Cline插件配置教程:免费使用Claude 3.7提升编程效率

 2025年最新VSCode Cline插件安装配置教程&#xff0c;详解多种免费使用Claude 3.7的方法&#xff0c;集成DeepSeek-R1与5大实用功能&#xff0c;专业编程效率提升指南。 Cline是VSCode中功能最强大的AI编程助手插件之一&#xff0c;它能与Claude、OpenAI等多种大模型无缝集…

考研英一真题学习笔记 2018年

2018 年全国硕士研究生招生考试 英语 &#xff08;科目代码&#xff1a;201&#xff09; Section Ⅰ Use of English Directions: Read the following text. Choose the best word(s) for each numbered blank and mark A, B, C or D on the ANSWER SHEET. (10 points) Trust i…

华硕服务器-品类介绍

目录 一、核心产品线解析 1. 机架式服务器 2. 塔式服务器 3. 高密度计算服务器 二、关键技术与模组配置 1. 主板与管理模块 2. 电源与散热 3. 存储与网络 三、应用场景与行业解决方案 1. 人工智能与高性能计算 2. 云计算与虚拟化 3. 边缘计算与工业物联网 一、核心…

硅基计划2.0 学习总结 贰

一、程序逻辑控制&#xff08;顺序、选择&循环&#xff09; 顺序结构就不多介绍了&#xff0c;就是各个语句按照先后顺序进行执行 &#xff08;1&#xff09;选择结构 三大选择类型&#xff1a;if、if-else、if-else if-else以及悬浮else的问题 基本已经在之前在C语言文章…

RabbitMQ最新入门教程

文章目录 RabbitMQ最新入门教程1.什么是消息队列2.为什么使用消息队列3.消息队列协议4.安装Erlang5.安装RabbitMQ6.RabbitMQ核心模块7.RabbitMQ六大模式7.1 简单模式7.2 工作模式7.3 发布订阅模式7.4 路由模式7.5 主题模式7.6 RPC模式 8.RabbitMQ四种交换机8.1 直连交换机8.2 主…

工具学习_VirusTotal使用

VirusTotal Intelligence 允许用户在其庞大的数据集中进行搜索&#xff0c;以查找符合特定条件的文件&#xff0c;例如哈希值、杀毒引擎检测结果、元数据信息、提交时的文件名、文件结构特征、文件大小等。可以说&#xff0c;它几乎是恶意软件领域的“谷歌搜索引擎”。 网页使…

计算机系统----软考中级软件设计师(自用学习笔记)

目录 1、计算机的基本硬件系统 2、CPU的功能 3、运算器的组成 4、控制器 5、计算机的基本单位 6、进制转换问题 7、原码、反码、补码、移码 8、浮点数 9、寻址方式 10、奇偶校验码 11、海明码 12、循环冗余校验码 13、RISC和CISC 14、指令的处理方式 15、存储器…

扬州卓韵酒店用品:优质洗浴用品,提升酒店满意度与品牌形象

在酒店提供的服务里&#xff0c;沐浴用品占据了非常重要的地位&#xff0c;其质量与种类直接关系到客人洗澡时的感受。好的沐浴用品能让客人洗澡时感到舒心和快乐&#xff0c;反之&#xff0c;质量不好的用品可能会影响客人整个住宿期间的愉悦心情。挑选恰当的洗浴用品不仅能够…

学习笔记:黑马程序员JavaWeb开发教程(2025.4.5)

12.4 登录认证-登录校验-会话跟踪方案一 设置cookie&#xff0c;服务器给浏览器响应数据&#xff0c;通过control方法形参当中获取response&#xff0c;调用response当中的addCookie方法实现 获取cookie&#xff0c;调用getCookie方法 用户可以通过浏览器设置禁用cookie 跨域…

进程替换讲解

1. 基本概念 1.1 进程替换 vs. 进程创建 进程创建&#xff1a;使用fork()或clone()等系统调用创建一个新的子进程&#xff0c;子进程是父进程的副本&#xff0c;拥有相同的代码和数据。进程替换&#xff1a;使用exec系列函数在当前进程中加载并执行一个新的程序&#xff0c;替…

【微服务】SpringBoot + Docker 实现微服务容器多节点负载均衡详解

目录 一、前言 二、前置准备 2.1 基本环境 2.2 准备一个springboot工程 2.2.1 准备几个测试接口 2.3 准备Dockerfile文件 2.4 打包上传到服务器 三、制作微服务镜像与运行服务镜像 3.1 拷贝Dockerfile文件到服务器 3.2 制作服务镜像 3.3 启动镜像服务 3.4 访问一下服…