十三、Spring对事务的支持

news2024/9/22 2:11:20

1 事务概述

  • 什么是事务
    • 在一个业务流程当中,通常需要多条DML(insert delete update)语句共同联合才能完成,这多条DML语句必须同时成功,或者同时失败,这样才能保证数据的安全。
    • 多条DML要么同时成功,要么同时失败,这叫做事务。
    • 事务:Transaction(tx)
  • 事务的四个处理过程:
    • 第一步:开启事务 (start transaction)
    • 第二步:执行核心业务代码
    • 第三步:提交事务(如果核心业务处理过程中没有出现异常)(commit transaction)
    • 第四步:回滚事务(如果核心业务处理过程中出现异常)(rollback transaction)
  • 事务的四个特性:
    • A 原子性:事务是最小的工作单元,不可再分。
    • C 一致性:事务要求要么同时成功,要么同时失败。事务前和事务后的总量不变。
    • I 隔离性:事务和事务之间因为有隔离性,才可以保证互不干扰。
    • D 持久性:持久性是事务结束的标志。

2 Spring对事务的支持


Spring实现事务的两种方式

  • 编程式事务
    • 通过编写代码的方式来实现事务的管理。
  • 声明式事务
    • 基于注解方式
    • 基于XML配置方式

Spring事务管理API

Spring对事务的管理底层实现方式是基于AOP实现的。采用AOP的方式进行了封装。所以Spring专门针对事务开发了一套API,API的核心接口如下:
在这里插入图片描述
PlatformTransactionManager接口:spring事务管理器的核心接口。在Spring6中它有两个实现:

  • DataSourceTransactionManager:支持JdbcTemplate、MyBatis、Hibernate等事务管理。
  • JtaTransactionManager:支持分布式事务管理。

声明式事务之注解实现方式

以银行账户转账为例学习事务。两个账户act-001和act-002。act-001账户向act-002账户转账10000,必须同时成功,或者同时失败。(一个减成功,一个加成功, 这两条update语句必须同时成功,或同时失败。)
连接数据库的技术采用Spring框架的JdbcTemplate。
采用三层架构搭建:
在这里插入图片描述

第一步:准备数据库表

在这里插入图片描述
在这里插入图片描述

第二步:引入依赖
<?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>org.example</groupId>
    <artifactId>spring6-010-tx-bank</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <!--依赖-->
    <dependencies>
        <!--spring context-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>6.0.2</version>
        </dependency>
        <!--spring jdbc-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>6.0.2</version>
        </dependency>
        <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.30</version>
        </dependency>
        <!--德鲁伊连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.13</version>
        </dependency>
        <!--@Resource注解-->
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <version>2.1.1</version>
        </dependency>
        <!--junit-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

</project>
第三步:创建包结构

com.powernode.bank.pojo
com.powernode.bank.service
com.powernode.bank.service.impl
com.powernode.bank.dao
com.powernode.bank.dao.impl

第四步:准备POJO类
package com.powernode.bank.pojo;

/**
 * 银行账户类
 */
public class Account {
    private String actno;
    private Double balance;
    // 省略构造方法,get、set方法,toString方法
第五步:编写持久层
package com.powernode.bank.dao;

import com.powernode.bank.pojo.Account;

/**
 * 专门负责账户信息的CRUD操作
 * DAO中只执行SQL语句,没有任何业务逻辑
 */
public interface AccountDao {
    /**
     * 根据账号查询账户信息
     * @param actno
     * @return
     */
    Account selectByActno(String actno);

    /**
     * 更新账户信息
     * @param act
     * @return
     */
    int update(Account act);
}
package com.powernode.bank.dao.impl;

import com.powernode.bank.dao.AccountDao;
import com.powernode.bank.pojo.Account;
import jakarta.annotation.Resource;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository("accountDao")
public class AccountDaoImpl implements AccountDao {

    @Resource(name = "jdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    @Override
    public Account selectByActno(String actno) {
        String sql = "select actno, balance from t_act where actno = ?";
        Account account = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Account.class), actno);
        return account;
    }

    @Override
    public int update(Account act) {
        String sql = "update t_act set balance = ? where actno = ?";
        int count = jdbcTemplate.update(sql, act.getBalance(), act.getActno());
        return count;
    }
}
第六步:编写业务层
package com.powernode.bank.service;

/**
 * 业务接口
 * 事务是在这个接口下控制的
 */
public interface AccountService {
    /**
     * 转账业务方法
     * @param fromActno 转出账户
     * @param toActno 转入账户
     * @param money 转账金额
     */
    void transfer(String fromActno, String toActno, double money);
}

在service类上或方法上添加@Transactional注解
在类上添加该注解,该类中所有的方法都有事务。在某个方法上添加该注解,表示只有这个方法使用事务。

package com.powernode.bank.service.impl;

import com.powernode.bank.dao.AccountDao;
import com.powernode.bank.pojo.Account;
import com.powernode.bank.service.AccountService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("accountService")
@Transactional
public class AccountServiceImpl implements AccountService {

    @Resource(name = "accountDao")
    private AccountDao accountDao;

    @Override
    // 控制事务
    //@Transactional
    public void transfer(String fromActno, String toActno, double money) {
        // 查询转出账户的余额是否充足
        Account fromAct = accountDao.selectByActno(fromActno);
        if (fromAct.getBalance() < money) {
            throw new RuntimeException("余额不足");
        }
        
        // 余额充足
        Account toAct = accountDao.selectByActno(toActno);

        // 将内存中两个对象的余额修改
        fromAct.setBalance(fromAct.getBalance() - money);
        toAct.setBalance(toAct.getBalance() + money);

        // 数据库更新
        int count = accountDao.update(fromAct);

        /*// 模拟异常
        String s = null;
        s.toString();*/
        
        count += accountDao.update(toAct);

        if (count != 2) {
            throw new RuntimeException("转账失败");
        }
    }
}
第七步:编写Spring配置文件

在spring配置文件中配置事务管理器。
在spring配置文件中引入tx命名空间。
在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:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--组件扫描-->
    <context:component-scan base-package="com.powernode.bank"/>

    <!--配置数据源-->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/spring6"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
     </bean>
    <!--配置JdbcTemplate-->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!--配置事务管理器-->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--开启事务注解驱动器-->
    <tx:annotation-driven transaction-manager="txManager"/>
</beans>
第八步:编写表示层(测试程序)
package com.powernode.bank.test;

import com.powernode.bank.service.AccountService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTXTest {
    @Test
    public void testSpringTX(){
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
        AccountService accountService = applicationContext.getBean("accountService", AccountService.class);
        try{
            accountService.transfer("act-001","act-002",10000);
            System.out.println("转账成功");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

在这里插入图片描述
数据变化:
在这里插入图片描述
模拟异常

在这里插入图片描述
在这里插入图片描述

事务属性

事务中的重点属性:

  • 事务传播行为
    Propagation propagation() default Propagation.REQUIRED;
  • 事务隔离级别
    Isolation isolation() default Isolation.DEFAULT;
  • 事务超时
    int timeout() default -1;
  • 只读事务
    boolean readOnly() default false;
  • 设置出现哪些异常回滚事务
    Class<? extends Throwable>[] rollbackFor() default {};
  • 设置出现哪些异常不回滚事务
    Class<? extends Throwable>[] noRollbackFor() default {};
事务传播行为

什么是事务的传播行为?

在service类中有a()方法和b()方法,a()方法上有事务,b()方法上也有事务,当a()方法执行过程中调用了b()方法,事务是如何传递的?合并到一个事务里?还是开启一个新的事务?这就是事务传播行为。

事务传播行为在spring框架中被定义为枚举类型:

public enum Propagation {
    REQUIRED(0),
    SUPPORTS(1),
    MANDATORY(2),
    REQUIRES_NEW(3),
    NOT_SUPPORTED(4),
    NEVER(5),
    NESTED(6);

一共有七种传播行为:

  • REQUIRED:支持当前事务,如果不存在就新建一个(默认)【没有就新建,有就加入
  • SUPPORTS:支持当前事务,如果当前没有事务,就以非事务方式执行【有就加入,没有就不管了
  • MANDATORY:必须运行在一个事务中,如果当前没有事务正在发生,将抛出一个异常【有就加入,没有就抛异常
  • REQUIRES_NEW:开启一个新的事务,如果一个事务已经存在,则将这个存在的事务挂起【不管有没有,直接开启一个新事务,开启的新事务和之前的事务不存在嵌套关系,之前事务被挂起
  • NOT_SUPPORTED:以非事务方式运行,如果有事务存在,挂起当前事务【不支持事务,存在就挂起
  • NEVER:以非事务方式运行,如果有事务存在,抛出异常【不支持事务,存在就抛异常
  • NESTED:如果当前正有一个事务在进行中,则该方法应当运行在一个嵌套式事务中。被嵌套的事务可以独立于外层事务进行提交或回滚。如果外层事务不存在,行为就像REQUIRED一样。【有事务的话,就在这个事务里再嵌套一个完全独立的事务,嵌套的事务可以独立的提交和回滚。没有事务就和REQUIRED一样。
@Transactional(propagation = Propagation.REQUIRED)

事务隔离级别

事务隔离级别类似于教室A和教室B之间的那道墙,隔离级别越高表示墙体越厚。隔音效果越好。

数据库中读取数据存在的三大问题:(三大读问题)

  • 脏读:读取到没有提交到数据库的数据,叫做脏读。
  • 不可重复读:在同一个事务当中,第一次和第二次读取的数据不一样。
  • 幻读:读到的数据是假的。

事务隔离级别包括四个级别:

  • 读未提交:READ_UNCOMMITTED
    • 这种隔离级别,存在脏读问题,所谓的脏读(dirty read)表示能够读取到其它事务未提交的数据。
  • 读提交:READ_COMMITTED
    • 解决了脏读问题,其它事务提交之后才能读到,但存在不可重复读问题。
  • 可重复读:REPEATABLE_READ
    • 解决了不可重复读,可以达到可重复读效果,只要当前事务不结束,读取到的数据一直都是一样的。但存在幻读问题。
  • 序列化:SERIALIZABLE
    • 解决了幻读问题,事务排队执行。不支持并发。
隔离级别脏读不可重复读幻读
读未提交
读提交
可重复读
序列化

在Spring代码中如何设置隔离级别?
隔离级别在spring中以枚举类型存在:

public enum Isolation {
    DEFAULT(-1),
    READ_UNCOMMITTED(1),
    READ_COMMITTED(2),
    REPEATABLE_READ(4),
    SERIALIZABLE(8);
@Transactional(isolation = Isolation.READ_COMMITTED)
事务超时
@Transactional(timeout = 10)

以上代码表示设置事务的超时时间为10秒。

表示超过10秒如果该事务中所有的DML语句还没有执行完毕的话,最终结果会选择回滚。

默认值-1,表示没有时间限制。

这里有个坑,事务的超时时间指的是哪段时间?

在当前事务当中,最后一条DML语句执行之前的时间。如果最后一条DML语句后面很有很多业务逻辑,这些业务代码执行的时间不被计入超时时间。

以下代码的超时不会被计入超时时间

@Transactional(timeout = 10) // 设置事务超时时间为10秒。
public void save(Account act) {
    accountDao.insert(act);
    // 睡眠一会
    try {
        Thread.sleep(1000 * 15);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

以下代码超时时间会被计入超时时间

@Transactional(timeout = 10) // 设置事务超时时间为10秒。
public void save(Account act) {
    // 睡眠一会
    try {
        Thread.sleep(1000 * 15);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    accountDao.insert(act);
}

如果想让整个方法的所有代码都计入超时时间的话,可以在方法最后一行添加一行无关紧要的DML语句。


只读事务
@Transactional(readOnly = true)

将当前事务设置为只读事务,在该事务执行过程中只允许select语句执行,delete insert update均不可执行。

该特性的作用是:启动spring的优化策略。提高select语句执行效率。

如果该事务中确实没有增删改操作,建议设置为只读事务。

设置哪些异常回滚事务
@Transactional(rollbackFor = RuntimeException.class)

表示只有发生RuntimeException异常或该异常的子类异常才回滚。

设置哪些异常不回滚事务
@Transactional(noRollbackFor = NullPointerException.class)

表示发生NullPointerException或该异常的子类异常不回滚,其他异常则回滚。

事务的全注解式开发

编写一个类来代替配置文件

package com.powernode.bank;

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.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

// 代替spring.xml文件 在这个类中完成配置
@Configuration
// 组件扫描
@ComponentScan("com.powernode.bank")
// 开启事务注解
@EnableTransactionManagement
public class Spring6Config {

    // Spring框架,看到这个@Bean注解后,会调用这个被标注的方法,这个方法的返回值是一个java对象,这个java对象会自动纳入IoC容器管理。
    // 返回的对象就是Spring容器当中的一个Bean了。
    // 并且这个bean的名字是:dataSource
    @Bean(name = "dataSource")
    public DruidDataSource getDataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/spring6");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        return dataSource;
    }
    @Bean(name = "jdbcTemplate")
    //Spring在调用这个方法的时候会自动给我们传递过来一个dataSource对象。
    public JdbcTemplate getJdbcTemplate(DataSource dataSource){
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(dataSource);
        return jdbcTemplate;
    }

    @Bean(name = "txManager")
    public DataSourceTransactionManager getDataSourceTransactionManager(DataSource dataSource){
        DataSourceTransactionManager txManager = new DataSourceTransactionManager();
        txManager.setDataSource(dataSource);
        return txManager;
    }
}

测试程序

@Test
public void testNoXML(){
    ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Spring6Config.class);
    AccountService accountService = applicationContext.getBean("accountService", AccountService.class);
    try{
        accountService.transfer("act-001","act-002",10000);
        System.out.println("转账成功");
    }catch (Exception e){
        e.printStackTrace();
    }
}

声明式事务之XML实现方式

添加aspectj的依赖

<!--spring aspects依赖 Aspectj-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>6.0.2</version>
</dependency>

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:tx="http://www.springframework.org/schema/tx"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--组件扫描-->
    <context:component-scan base-package="com.powernode.bank"/>

    <!--配置数据源-->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/spring6"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </bean>
    <!--配置JdbcTemplate-->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!--配置事务管理器-->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!--配置通知-->
    <!--在通知中要关联事务管理器-->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <!--配置通知的相关属性-->
        <tx:attributes>
            <!--事务属性都可以在这配置-->
            <tx:method name="transfer" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
            <tx:method name="save*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
            <tx:method name="delete*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
            <tx:method name="update*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
            <tx:method name="modify*" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
            <tx:method name="query*" read-only="true"/>
            <tx:method name="select*" read-only="true"/>
            <tx:method name="find*" read-only="true"/>
            <tx:method name="get*" read-only="true"/>
        </tx:attributes>
    </tx:advice>

    <!--配置切面-->
    <aop:config>
        <!--切点-->
        <aop:pointcut id="txPointcut" expression="execution(* com.powernode.bank.service..*(..))"/>
        <!--配置切面-->
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
    </aop:config>
</beans>

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

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

相关文章

Antlr4:使用grun命令,触发NoClassDefFoundError

1. 意外的发现 在学习使用grun命令时&#xff0c;从未遇到过错误 最近使用grun命令&#xff0c;却遇到了NoClassDefFoundError的错误&#xff0c;使得grun测试工具无法成功启动 错误复现&#xff1a; 使用antlr4命令编译Hello.g4文件&#xff0c;并为指定package&#xff08;…

人工智能学习07--pytorch10--目标检测:RCNN、Faster RCNN

括号里都是弹幕大佬的高赞发言 1 前言 Two Stage检测过程分两步走 前景&#xff1a;需要检测的目标 背景&#xff1a;不感兴趣的 生成候选框&#xff1a;将感兴趣目标框选出来&#xff0c;但是没有进行分类 具体使用哪一种&#xff0c;根据项目需求 自定义数据集 自己写一…

CAS 与 ABA问题

本文通过学习&#xff1a;周阳老师-尚硅谷Java大厂面试题第二季 总结的CAS和ABA相关的笔记一、CAS1、CAS定义CAS Compare-And-Swap&#xff0c;它是CPU并发原语。比较当前工作内存中的值和主物理内存中的值&#xff0c;如果相同则执行规定操作&#xff0c;否者继续比较直到主内…

【MySQL】第18章_MySQL8其它新特性

第18章_MySQL8其它新特性 1. MySQL8新特性概述 MySQL从5.7版本直接跳跃发布了8.0版本&#xff0c;可见这是一个令人兴奋的里程碑版本。MySQL 8版本在功能上做了显著的改进与增强&#xff0c;开发者对MySQL的源代码进行了重构&#xff0c;最突出的一点是多MySQL Optimizer优化器…

gitHub远程库

创建远程仓库注册一个gutHub账户点击号&#xff0c;在点击New repository新建一个远程仓库仓库名一般跟本地库的名称一致public公共的开源private私有的不公开远程仓库操作创建远程仓库别名基本语法git remote -v &#xff1a; 查看当前所有远程地址别名git remote add 别名 远…

ABAP ALV和OOALV设置单元格颜色,编辑

首先给大家分享一篇博客: REUSE_ALV_GRID_DISPLAY_LVC-可编辑单元格 文章目录单元格编辑单元格/行-颜色效果展示**需求:**我是想实现某个单元格可根据数据来判断是否是可以进行编辑的或要添加一个什么样的颜色. 我们需要用到下面的三个结构 ALV 控制: 单元格的类型表:LVC_T_ST…

Nios II软件开发流程简介(含工程)

软件安装 Nios II Eclipse软件打不开 ​ 安装完成quartus后&#xff0c;想要打开Nios II Eclipse软件&#xff0c;点击软件后发现没有任何反应。 ​ 这时要到安装目录C:\intelFPGA_pro\20.3\nios2eds\bin下&#xff0c;打开readme文件。 ​ 按readme中的内容下载eclipse-cpp-…

VTK中如何 搜索 目标点 最近的点或者点集( vtkPointLocator )

背景: 在vtk使用过程中,我们有时要搜索点或者cell最近的 单元, 仔细看源码,有时无法判断其具体是什么样子,因而这里做了可视化处理,方便我们更深刻的理解 vtkPointLocator 类型函数的使用; 过程: 1.了解其继承关系是必要的: 2.开始探索该函数的一些效果: 我们会将原始数据…

vmware安装redhat enterprise linux server 9.1

vmware安装redhat enterprise linux server 9.11、安装系统1.1 镜像文件2、更新系统2.1 注册系统到redhat软件仓库2.2 更新系统1、安装系统 1.1 镜像文件 官网下载&#xff1a;https://developers.redhat.com/products/rhel/download 2、更新系统 2.1 注册系统到redhat软件…

【编写中】html5+go+websocket不到150行代码,实现一个在线实时聊天的功能

阮一峰websocket 相关参考 websocket 什么是websocket 在了解什么是websocket之前&#xff0c;我们下说一说http&#xff0c;因为HTTP我们太熟了。我们知道&#xff0c;HTTP是一种基于应用层的网络协议&#xff0c;往往都是一个请求&#xff0c;一个相应。websocket呢&#…

为啥用 时序数据库 TSDB

前言 其实我之前是不太了解时序数据库以及它相关的机制的&#xff0c;只是大概知晓它的用途。但因为公司的业务需求&#xff0c;我意外参与并主导了公司内部开源时序数据库influxdb的引擎改造&#xff0c;所以我也就顺理成章的成为时序数据库“从业者”。 造飞机的人需要时刻…

VMware vCenter Server的安装和使用

准备工作 首先去官网下载好VCenter Server&#xff0c;然后准备安装&#xff0c;我这里下载的是6.0对应的镜像为VMware-VIMSetup-all-6.0.0-2656757.iso 需要注意&#xff1a; 开始安装 和安装其他操作系统一样&#xff0c;把镜像放入光驱或解压缩&#xff0c;我这里是在…

Dropout Reduces Underfitting论文解读

Dropout 在欠拟合的应用Dropout Reduces Underfitting&#xff08;2023.3.2&#xff09;写在前面摘要一、简介二、重新审视过拟合和欠拟合三、Dropout如何减少欠拟合四、方法五、实验早期随机失活分析晚期随机失活&#xff08;Late Dropout&#xff09;六、下游任务七、相关工作…

【零代码工具推荐】Max Creation Graph (MCG) 可视化图形编程工具

从3dMax 2016开始新加入了一个很牛great的功能&#xff0c;也就是“MCG”全称是Max Creation Graph&#xff0c;MCG可以让用户使用全可视化节点工作流程来创建修改器&#xff0c;几何体工具插件&#xff0c;使用MCG&#xff0c;可以创建一个新的插件&#xff0c;没错是插件&…

【大数据实时数据同步】超级详细的生产环境OGG(GoldenGate)12.2实时异构同步Oracle数据部署方案(下)

系列文章目录 【大数据实时数据同步】超级详细的生产环境OGG(GoldenGate)12.2实时异构同步Oracle数据部署方案(上) 【大数据实时数据同步】超级详细的生产环境OGG(GoldenGate)12.2实时异构同步Oracle数据部署方案(中) 【大数据实时数据同步】超级详细的生产环境OGG(GoldenGate…

要点提炼|《数字中国建设整体布局规划》,看这一篇就够了!

《数字中国建设整体布局规划》/// 近日&#xff0c;中共中央、国务院印发了《数字中国建设整体布局规划》&#xff08;以下简称“《规划》”&#xff09;&#xff0c;作为影响中国未来发展的重磅文件&#xff0c;被业界评价为“数字挂帅时代来临”。《数字中国建设整体布局规划…

【持续集成】Jenkins详细教程

文章目录一、jenkins是什么&#xff1f;二、CI/CD是什么&#xff1f;三、使用Jenkins进行PHP代码(单元)测试、打包。1.General2.源码管理3.构建触发器4.构建环境5.构建6.构建后操作7.其他相关配置四、进行jenkins project 构建五、构建结果说明六、jenkins权限管理最后&#xf…

【拼图】拼图游戏-微信小程序开发流程详解

还记得小时候玩过的经典拼图游戏吗&#xff0c;上小学时&#xff0c;在路边摊用买个玩具&#xff0c;是一个正方形盒子形状&#xff0c;里面装的是图片分割成的很多块&#xff0c;还差一块&#xff0c;怎么描述好呢&#xff0c;和魔方玩具差不多&#xff0c;有没有听说叫二维的…

【Leetcode——重排链表】

文章目录一、重排链表思路1.思路2.总结一、重排链表 对于这道题&#xff0c;有两种思路&#xff1a; 思路1. 1.使用一个线性表&#xff0c;存储链表中的每个节点&#xff0c;然后按照题目的条件&#xff0c;来链接线性表的各个节点即可。 使用左下标和右下标来定位线性表中的…

硬件学习 软件 Cadence day09 芯片PCB 封装导出DXF 文件

1.打开自己要导出 DXF 文件的 PCB 封装 (Allegro 软件) 2.导出DXF 文件的按钮 1.点击按钮&#xff0c;打开窗口 2.填写数据 3. 按下 Edit... 按钮 4. 编辑数据 5. 导出数据 &#xff0c;生成DXF 文件 下面的选项自己选择 &#xff1a; Color mapping &#xff1a; …