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

Spring-事务2

文章目录

  • 前言
  • 一、事务的特性(ACID)
  • 二、事务的隔离级别
  • 三、spring中的事务
      • 平台事务管理器.
      • 事务定义
        • ISOLation_XXX:**事务隔离级别.**
        • PROPAGATION_XXX:**事务的传播行为**.
      • 事务状态
    • 关系:
  • 四、使用XML文件配置事务
    • 1、 搭建环境
    • 2、 配置及业务编写
    • 3、 测试
  • 五、使用注解形式进行事务开发
  • 总结


前言

事务是逻辑上的一组操作的集合,要么全部成功,要么全部失败。在实际的业务场景中,事务的应用场景范围很广泛,例如转账,订单,支付等


一、事务的特性(ACID)

事务有四大特性:

  • 原子性:事务不可分割
  • 一致性:事务执行的前后,数据完整性保持一致.
  • 隔离性:一个事务执行的时候,不应该受到其他事务的打扰
  • 持久性:一旦结束,数据就永久的保存到数据库.

二、事务的隔离级别

在实际的开发中,可能会出现以下几种由数据操作引起的异常情况:
如果不考虑隔离性:

  • 脏读:一个事务读到另一个事务未提交数据
  • 不可重复读:一个事务读到另一个事务已经提交数据(update)导致一个事务多次查询结果不一致
  • 虚读:一个事务读到另一个事务已经提交数据(insert)导致一个事务多次查询结果不一致

事务存在几种隔离级别:

  • 未提交读:以上情况都有可能发生。
  • 已提交读:避免脏读,但不可重复读,虚读是有可能发生。
  • 可重复读:避免脏读,不可重复读,但是虚读有可能发生。
  • 串行化:避免以上所有情况.

三、spring中的事务

后端分层开发中,事务应用于Service层中。spring提供了事务管理API

平台事务管理器.

PlatformTransactionManager

  • getTransaction(TransactionDefinition definition) :开启事务
  • rollback(TransactionStatus status) :回滚事务
  • commit(TransactionStatus status) :提交事务

Spring为不同的持久化框架提供了不同PlatformTransactionManager接口实现

使用Spring JDBC或iBatis 进行持久化数据时使用(重点)

  • org.springframework.jdbc.datasource.DataSourceTransactionManager

使用Hibernate进行持久化数据时使用

  • org.springframework.orm.hibernate.HibernateTransactionManager

使用JPA进行持久化时使用

  • org.springframework.orm.jpa.JpaTransactionManager

当持久化机制是Jdo时使用

  • org.springframework.jdo.JdoTransactionManager

使用一个JTA实现来管理事务,在一个事务跨越多个资源时必须使用

  • org.springframework.transaction.jta.JtaTransactionManager

事务定义

TransactionDefinition

ISOLation_XXX:事务隔离级别.

ISOLATION_DEFAULT:默认级别. Mysql --> repeatable_read | Oracle -->> read_commited
级别如下:

  • ISOLATION_READ_UNCOMMITTED : 读未提交
  • ISOLATION_READ_COMMITTED : 读已提交
  • ISOLATION_REPEATABLE_READ :可重复读
  • ISOLATION_SERIALIZABLE :串行化

PROPAGATION_XXX:事务的传播行为.

事务的传播行为是用来解决实际开发中的问题
传播行为是指:解决业务层调用事务的关系。

  • PROPAGATION_REQUIRED: 支持当前事务,如果不存在 就新建一个

A,B 如果A有事务,B使用A的事务,如果A没有事务,B就开启一个新的事务.(A,B是在一个事务中。)

  • PROPAGATION_SUPPORTS: 支持当前事务,如果不存在,就不使用事务

A,B 如果A有事务,B使用A的事务,如果A没有事务,B就不使用事务.

  • PROPAGATION_MANDATORY: 支持当前事务,如果不存在,抛出异常

A,B 如果A有事务,B使用A的事务,如果A没有事务,抛出异常.

  • PROPAGATION_REQUIRES_NEW: 如果有事务存在,挂起当前事务,创建一个新的事务

A,B 如果A有事务,B将A的事务挂起,重新创建一个新的事务.(A,B不在一个事务中.事务互不影响.)

  • PROPAGATION_NOT_SUPPORTED: 以非事务方式运行,如果有事务存在,挂起当前事务

A,B 非事务的方式运行,A有事务,就会挂起当前的事务.

  • PROPAGATION_NEVER: 以非事务方式运行,如果有事务存在,抛出异常

  • PROPAGATION_NESTED: 如果当前事务存在,则嵌套事务执行

基于SavePoint技术.
A,B A有事务,A执行之后,将A事务执行之后的内容保存到SavePoint.B事务有异常的话,用户需要自己设置事务提交还是回滚.

  • 常用:(重点)
    PROPAGATION_REQUIRED
    PROPAGATION_REQUIRES_NEW
    PROPAGATION_NESTED

事务状态

TransactionStatus

  • 是否有保存点

  • 是否是一个新的事务

  • 事务是否已经提交

关系:

关系:PlatformTransactionManager通过TransactionDefinition设置事务相关信息管理事务,管理事务过程中,产生一些事务状态,状态由TransactionStatus记录。

四、使用XML文件配置事务

spring支持声明式事务管理,只需要配置文件,不需要额外的编写代码
演示如下:

1、 搭建环境

创建account表并插入两条数据

CREATE TABLE `account` (`id` int(11) NOT NULL AUTO_INCREMENT,`money` double DEFAULT NULL,PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;INSERT INTO `account` VALUES ('1',  '1000');
INSERT INTO `account` VALUES ('2',  '1000');

新建项目略
导入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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.wmj</groupId><artifactId>SpringTX</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties><dependencies><!-- spring相关依赖,版本必须保持一致 --><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.3.24</version></dependency><!--spring数据连接支持 --><dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>5.3.24</version></dependency><!--aop支持 --><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>1.9.9.1</version></dependency><!-- 事务 --><dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>5.3.24</version></dependency><!-- mybatis相关依赖 --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.5.11</version></dependency><!-- myabtis整合spring依赖,必须导入 --><dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>2.0.7</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.31</version></dependency><!--德鲁伊数据连接池支持 --><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.2.9</version></dependency><!--lombok注解支持 --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.24</version></dependency><!--log4j日志 --><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><!--单元测试 --><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency></dependencies>
</project>

2、 配置及业务编写

配置mybatis-config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configurationPUBLIC "-//mybatis.org//DTD Config 3.0//EN""https://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><!-- 配置日志 --><settings><setting name="logImpl" value="LOG4J"/></settings></configuration>

配置日志

log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

配置数据源

db.username = 帐号
db.password = 密码
db.url = jdbc:mysql:///库名?serverTimezone=Asia/Shanghai&characterEncoding=UTF8
db.driverClassName = com.mysql.cj.jdbc.Driver

搭建后端业务代码

控制层

package com.wmj.controller;import com.wmj.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:04*/
@Controller
public class TestController {@Autowiredprivate TestService service;public void testTx(Integer id1,Integer id2,Double money){service.transferMoney(id1,id2,money);}
}

业务层接口及其实现类

package com.wmj.service;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:10*/public interface TestService {void transferMoney(Integer id1, Integer id2, Double money);
}
package com.wmj.service.impl;import com.wmj.mapper.TestMapper;
import com.wmj.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:11*/
@Service
public class TestServiceImpl implements TestService {@Autowiredprivate TestMapper mapper;@Overridepublic void transferMoney(Integer id1, Integer id2, Double money) {mapper.dmoney(id1,money);int a =  1/0;mapper.amoney(id2,money);}
}

持久层接口及其xml数据访问

package com.wmj.mapper;import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:12*/
@Repository
public interface TestMapper {Integer dmoney(@Param("id1") Integer id1, @Param("money") Double money);Integer amoney(@Param("id2") Integer id2, @Param("money") Double money);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.wmj.mapper.TestMapper"><update id="dmoney">update account set money = money - #{money} where id = #{id1}</update><update id="amoney">update account set money = money + #{money} where id = #{id2}</update>
</mapper>

配置spring核心配置文件application.xml

<?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/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><!-- bean definitions here --><!-- 扫描包下的注解 --><context:component-scan base-package="com.wmj"></context:component-scan><!-- 引入db.properties配置文件 --><context:property-placeholder location="classpath:db.properties"></context:property-placeholder><!-- 配置数据库链接 --><bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"><property name="username" value="${db.username}"></property><property name="password" value="${db.password}"></property><property name="url" value="${db.url}"></property><property name="driverClassName" value="${db.driverClassName}"></property></bean><!-- 配置SqlSession --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- dataSource属性(必选属性) --><property name="dataSource" ref="dataSource"></property><!-- configLocation属性配置mybatis-config.xml(非必选属性)--><property name="configLocation" value="classpath:mybatis-config.xml"></property><!-- mapperLocations属性用于配置Mapper.xml文件所在位置 (非必选属性)--><property name="mapperLocations" value="classpath:mapper/*.xml"></property></bean><!-- 扫描Mapper --><bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.wmj.mapper"></property></bean><!-- 事务核心管理器,封装了所有事务操作. 依赖于连接池 --><bean name="transactionManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><!-- 配置事务通知 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><!-- 企业中配置CRUD方法一般使用方法名+通配符*的形式配置通知,此时类中的方法名要和配置的方法名一致 --><!-- 以方法为单位,指定方法应用什么事务属性isolation:用于指定事务的隔离级别。默认值是DEFAULT,表示使用数据库的默认隔离级别。propagation:用于指定事务的传播行为。默认值是REQUIRED,表示一定会有事务,增删改的选择。查询方法可以选择SUPPORTS。read-only:用于指定事务是否只读。只有查询方法才能设置为true。默认值是false,表示读写。timeout:用于指定事务的超时时间,默认值是-1,表示永不超时。如果指定了数值,以秒为单位。rollback-for:用于指定一个异常,当产生该异常时,事务回滚,产生其他异常时,事务不回滚。没有默认值。表示任何异常都回滚。no-rollback-for:用于指定一个异常,当产生该异常时,事务不回滚,产生其他异常时事务回滚。没有默认值。表示任何异常都回滚。--><tx:method name="transferMoney" isolation="REPEATABLE_READ"propagation="REQUIRED" read-only="false" /></tx:attributes></tx:advice><!-- 配置织入 --><aop:config><!-- 配置切点表达式 --><aop:pointcut expression="execution(* com.wmj.service.impl.*ServiceImpl.*(..))"id="txPc" /><!-- 配置切面 : 通知+切点 advice-ref:通知的名称 pointcut-ref:切点的名称 --><aop:advisor advice-ref="txAdvice" pointcut-ref="txPc" /></aop:config></beans>

3、 测试

package com.test;import com.wmj.controller.TestController;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:02*/public class Demo1 {@Testpublic void testTX(){ClassPathXmlApplicationContext applicationContext =new ClassPathXmlApplicationContext("application.xml");TestController controller = (TestController)applicationContext.getBean("testController");controller.testTx(1,2,200.00);}
}

执行结果:
当没有遇到异常时,转账能正常执行,不在演示,此处演示当遇到异常时的事务效果
代码执行前数据库:
在这里插入图片描述

在这里插入图片描述
当遇到异常,代码终止执行,此时数据库

在这里插入图片描述
转账并没有进行提交,此时说明我们的事务配置成功!

五、使用注解形式进行事务开发

spring给我们提供了事务注解开发的方式,大大减少了代码编写,十分方便

创建项目配置基本与上方相同,我们将application.xml内容进行修改如下:

<?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:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context" 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.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- bean definitions here --><!-- 导入外部配置文件 db.properties --><context:property-placeholder location="classpath:db.properties"></context:property-placeholder><!-- 配置数据源对象 --><bean id="datasource" class="com.alibaba.druid.pool.DruidDataSource"><!-- 导入 db.properties 中的值--><property name="username" value="${db.username}"></property><property name="password" value="${db.password}"></property><property name="url" value="${db.url}"></property><property name="driverClassName" value="${db.driver}"></property></bean><!-- 扫描对应包下的注解 --><context:component-scan base-package="com.wmj"></context:component-scan><!-- 配置sqlSessionFactory --><bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 必选配置 --><property name="dataSource" ref="datasource"></property><!-- 非必选属性,根据自己需求去配置 --><!-- 导入 mybatis-config.xml --><property name="configLocation" value="classpath:mybatis-config.xml"></property><!-- 导入 Mapper.xml 文件,classpath后面不能有空格 --><property name="mapperLocations" value="classpath:mapper/*.xml"></property></bean><!-- 扫描 Mapper 接口,生成代理对象 --><bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"><!-- 指定扫描的具体位置 --><property name="basePackage" value="com.wmj.mapper"></property></bean><!-- 配置事务 --><!-- 事务平台管理器,封装了所有的事务操作,依赖数据源 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="datasource"></property></bean><!-- 开启注解驱动事务支持 --><tx:annotation-driven></tx:annotation-driven></beans>

将业务实现类改造如下:

package com.wmj.service.impl;import com.wmj.mapper.AccountMapper;
import com.wmj.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;/*** @Transactional 配置事务* 可以写在类上,也可以写在方法上*/
//@Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED,readOnly = false)
@Service
package com.wmj.service.impl;import com.wmj.mapper.TestMapper;
import com.wmj.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;/*** --效率,是成功的核心关键--** @Author lzl* @Date 2023/2/13 16:11*/
/*** @Transactional 配置事务* 可以写在类上,也可以写在方法上*/
//@Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED,readOnly = false)
@Service
public class TestServiceImpl implements TestService {@Autowiredprivate TestMapper mapper;@Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED,readOnly = false)@Overridepublic void transferMoney(Integer id1, Integer id2, Double money) {mapper.dmoney(id1,money);int a =  1/0;mapper.amoney(id2,money);}
}

测试略


总结

本次主要记录了spring的事务支持,及其两种开发方式。再会!!!

相关文章:

Spring-事务2

文章目录前言一、事务的特性&#xff08;ACID&#xff09;二、事务的隔离级别三、spring中的事务平台事务管理器.事务定义ISOLation_XXX&#xff1a;**事务隔离级别.**PROPAGATION_XXX&#xff1a;**事务的传播行为**.事务状态关系&#xff1a;四、使用XML文件配置事务1、 搭建…...

Windows Git Bash 配置

Windows Git Bash 配置 本文参考的文章&#xff1a; 在 Windows 的 Git Bash 中使用包管理器 - iris (ginshio.org)Git bash 安装 pacman & Windows 解压 zst 文件 | 伪斜杠青年 (lckiss.com) 一、Git的安装 Git 的安装应该是都会的&#xff0c;但还是应该说以下&#…...

java代码整合kettle9.3实现读取表中的数据,生成excel文件

java代码整合kettle9.3实现读取表中的数据&#xff0c;生成excel文件 1.简介 本次使用java代码整合kettle9.3版本&#xff0c;数据库使用mysql。 2.jar包导入 项目需要依赖部分kettle中的jar包&#xff0c;请将这部分jar包自行导入maven仓库。 <dependency><groupId…...

分享微信点餐小程序搭建步骤_微信点餐功能怎么做

线下餐饮实体店都开始摸索发展网上订餐服务。最多人选择的是入驻外卖平台&#xff0c;但抽成高&#xff0c;推广还要另买流量等问题&#xff0c;也让不少商家入不敷出。在这种情况下&#xff0c;建立自己的微信订餐小程序&#xff0c;做自己的私域流量是另一种捷径。那么&#…...

4、数组、切片、map、channel

目录一、数组二、切片三、map四、channel五、引用类型一、数组 数组&#xff1a; 数组是块连续的内存空间&#xff0c;在声明的时候必须指定长度&#xff0c;且长度不能改变所以数组在声明的时候就可以把内存空间分配好&#xff0c;并赋上默认值&#xff0c;即完成了初始化数组…...

270 uuid

270 uuid 用途 For the creation of RFC4122 UUIDs 可靠性 10000 星星 适应于浏览器或者服务器 官网链接 https://www.npmjs.com/package/uuid https://github.com/uuidjs/uuid 基本使用 import { v4 as uuidv4 } from uuid; uuidv4(); // ⇨ 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3d…...

2023最新简历模板免费下载

下面分享5个简历模板网站&#xff0c;免费下载&#xff0c;建议收藏&#xff01; 2023用最漂亮的简历模板&#xff0c;让面试官眼前一亮。 1、菜鸟图库 个人简历模板|WORD文档模板免费下载 - 菜鸟图库 菜鸟图库除了有超多设计类素材之外&#xff0c;还有很多办公类素材&#…...

【CSS】元素居中总结-水平居中、垂直居中、水平垂直居中

【CSS】元素居中一、 水平居中1.行内元素水平居中&#xff08;1&#xff09;text-align2.块级元素水平居中2.1 margin&#xff08;1&#xff09;margin2.2布局&#xff08;1&#xff09;flex justify-content&#xff08;推荐&#xff09;&#xff08;2&#xff09; flexmargin…...

spring实现AOP

文章目录前言一、AOP的底层实现原理二、AOP的两种开发模式1.使用xml配置文件1.1 添加AOP依赖1.2 创建UserService1.3创建UserServiceImpl1.4创建通知类1.5 创建applicationContext.xml&#xff08;添加aop约束&#xff09;1.6 测试2.使用注解开发2.1 创建bean.xml文件配置注解方…...

neovim搭建cpp环境

文章目录Windowns下NeoVim搭建cpp环境NeoVim安装插件vim-plugindentLinevim-airlinectagstagbarcoc.vimWindowns下NeoVim搭建cpp环境 在开发过程中习惯在DIE环境中使用vim作为编辑器&#xff0c;在单独的编辑器也常使用gvim图形化编辑器。最近看到NeoVim的特性及兼容性方面不输…...

SpringBoot AES加密 PKCS7Padding 模式

AES 简介&#xff1a;DES 全称为Data Encryption Standard&#xff0c;即数据加密标准&#xff0c;是一种使用密钥加密的块算法&#xff0c;1977年被美国联邦政府的国家标准局确定为联邦资料处理标准&#xff08;FIPS&#xff09; AES 密码学中的高级加密标准&#xff08;Advan…...

按键输入驱动

目录 一、硬件原理 二、添加设备树 1、创建pinctrl 2、创建节点 3、检查 编译复制 三、修改工程模板​编辑 四、驱动编写 1、添加keyio函数 2、添加调用 3、驱动出口函数添加释放 4、添加原子操作 5、添加两个宏定义 6、初始化原始变量 7、打开操作 8、读操作 总体代…...

2023年第七周总周结 | 开学倒数第三周

为什么要做周总结&#xff1f; 1.避免跳相似的坑 2.客观了解上周学习进度并反思&#xff0c;制定可完成的下周规划 一、上周问题解决情况 晚上熬夜导致第二天学习状态不好 这周熬夜一天&#xff0c;晚上帮亲戚修手机到22:30&#xff0c;可能是晚上自己的事什么都没做&#xff…...

Springboot扫描注解类

Springboot扫描注解类的入口在AbstractApplicationContext的refresh中&#xff0c;对启动步骤不太了解的&#xff0c;可参考https://blog.csdn.net/leadseczgw01/article/details/128930925BeanDefinitionRegistryPostProcessor接口有多个实现类&#xff0c;扫描Controller、Se…...

Apache日志分析器

您的Apache HTTP服务器生成的日志数据是信息的宝库。使用这些信息&#xff0c;您可以判断您服务器的使用情况、找出漏洞所在&#xff0c;并设法改进服务器结构和整体性能。审核您的Apache日志可在以下情况派上用场&#xff0c;其中包括&#xff1a;识别和纠正频繁出现的错误以增…...

啪,还敢抛出异常

&#x1f649; 作者简介&#xff1a; 全栈领域新星创作者 &#xff1b;天天被业务折腾得死去活来的同时依然保有对各项技术热忱的追求&#xff0c;把分享变成一种习惯&#xff0c;再小的帆也能远航。 &#x1f3e1; 个人主页&#xff1a;xiezhr的个人主页 前言 去年又重新刷了…...

Apache JMeter 5.5 下载安装以及设置中文教程

Apache JMeter 5.5 下载安装以及设置中文教程JMeter下载Apache JMeter 5.5配置环境变量查看配置JDK配置JMeter环境变量运行JMeter配置中文版一次性永久设置正文JMeter 下载Apache JMeter 5.5 官方网站&#xff1a;Apache JMeter 官网 版本介绍&#xff1a; 版本中一个是Bina…...

string类模拟实现

了解过string常用接口后&#xff0c;接下来的任务就是模拟实现string类。 目录 VS下的string结构 默认成员函数和简单接口 string结构 c_str()、size()、capacity()、clear()、swap() 构造函数 拷贝构造函数 赋值重载 析构函数 访问及遍历 容量操作 reserve resize …...

cadence SPB17.4 S032 - allegro - 保存/载入光绘层定义

文章目录cadence SPB17.4 S032 - allegro - 保存/载入光绘层定义概述保存光绘层在新板子中载入已经保存的相同类型老板子定义好的光绘层定义文件碎碎念ENDcadence SPB17.4 S032 - allegro - 保存/载入光绘层定义 概述 以前布线完成, 准备出板厂文件时, 总是要手工重新建立光绘…...

微服务实战--高级篇:分布式缓存 Redis

分布式缓存 – 基于Redis集群解决单机Redis存在的问题 单机的Redis存在四大问题&#xff1a; 1.Redis持久化 Redis有两种持久化方案&#xff1a; RDB持久化AOF持久化 1.1.RDB持久化 RDB全称Redis Database Backup file&#xff08;Redis数据备份文件&#xff09;&#xf…...

css实现圆环展示百分比,根据值动态展示所占比例

代码如下 <view class""><view class"circle-chart"><view v-if"!!num" class"pie-item" :style"{background: conic-gradient(var(--one-color) 0%,#E9E6F1 ${num}%),}"></view><view v-else …...

大型活动交通拥堵治理的视觉算法应用

大型活动下智慧交通的视觉分析应用 一、背景与挑战 大型活动&#xff08;如演唱会、马拉松赛事、高考中考等&#xff09;期间&#xff0c;城市交通面临瞬时人流车流激增、传统摄像头模糊、交通拥堵识别滞后等问题。以演唱会为例&#xff0c;暖城商圈曾因观众集中离场导致周边…...

在四层代理中还原真实客户端ngx_stream_realip_module

一、模块原理与价值 PROXY Protocol 回溯 第三方负载均衡&#xff08;如 HAProxy、AWS NLB、阿里 SLB&#xff09;发起上游连接时&#xff0c;将真实客户端 IP/Port 写入 PROXY Protocol v1/v2 头。Stream 层接收到头部后&#xff0c;ngx_stream_realip_module 从中提取原始信息…...

工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配

AI3D视觉的工业赋能者 迁移科技成立于2017年&#xff0c;作为行业领先的3D工业相机及视觉系统供应商&#xff0c;累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成&#xff0c;通过稳定、易用、高回报的AI3D视觉系统&#xff0c;为汽车、新能源、金属制造等行…...

【碎碎念】宝可梦 Mesh GO : 基于MESH网络的口袋妖怪 宝可梦GO游戏自组网系统

目录 游戏说明《宝可梦 Mesh GO》 —— 局域宝可梦探索Pokmon GO 类游戏核心理念应用场景Mesh 特性 宝可梦玩法融合设计游戏构想要素1. 地图探索&#xff08;基于物理空间 广播范围&#xff09;2. 野生宝可梦生成与广播3. 对战系统4. 道具与通信5. 延伸玩法 安全性设计 技术选…...

处理vxe-table 表尾数据是单独一个接口,表格tableData数据更新后,需要点击两下,表尾才是正确的

修改bug思路&#xff1a; 分别把 tabledata 和 表尾相关数据 console.log() 发现 更新数据先后顺序不对 settimeout延迟查询表格接口 ——测试可行 升级↑&#xff1a;async await 等接口返回后再开始下一个接口查询 ________________________________________________________…...

NPOI Excel用OLE对象的形式插入文件附件以及插入图片

static void Main(string[] args) {XlsWithObjData();Console.WriteLine("输出完成"); }static void XlsWithObjData() {// 创建工作簿和单元格,只有HSSFWorkbook,XSSFWorkbook不可以HSSFWorkbook workbook new HSSFWorkbook();HSSFSheet sheet (HSSFSheet)workboo…...

tomcat入门

1 tomcat 是什么 apache开发的web服务器可以为java web程序提供运行环境tomcat是一款高效&#xff0c;稳定&#xff0c;易于使用的web服务器tomcathttp服务器Servlet服务器 2 tomcat 目录介绍 -bin #存放tomcat的脚本 -conf #存放tomcat的配置文件 ---catalina.policy #to…...

系统掌握PyTorch:图解张量、Autograd、DataLoader、nn.Module与实战模型

本文较长&#xff0c;建议点赞收藏&#xff0c;以免遗失。更多AI大模型应用开发学习视频及资料&#xff0c;尽在聚客AI学院。 本文通过代码驱动的方式&#xff0c;系统讲解PyTorch核心概念和实战技巧&#xff0c;涵盖张量操作、自动微分、数据加载、模型构建和训练全流程&#…...

Linux部署私有文件管理系统MinIO

最近需要用到一个文件管理服务&#xff0c;但是又不想花钱&#xff0c;所以就想着自己搭建一个&#xff0c;刚好我们用的一个开源框架已经集成了MinIO&#xff0c;所以就选了这个 我这边对文件服务性能要求不是太高&#xff0c;单机版就可以 安装非常简单&#xff0c;几个命令就…...