Spring6 對 集成MyBatis 開發運用(附有詳細的操作步驟)

来源:https://www.cnblogs.com/TheMagicalRainbowSea/p/18211700
-Advertisement-
Play Games

1. Spring6 對 集成MyBatis 開發運用(附有詳細的操作步驟) @目錄1. Spring6 對 集成MyBatis 開發運用(附有詳細的操作步驟)每博一文案2. 大概的實現步驟概述3. 詳細實現操作步驟4. Spring配置文件的 import,導入外部xml 配置5. 總結:6. 最 ...


1. Spring6 對 集成MyBatis 開發運用(附有詳細的操作步驟)

@

目錄


每博一文案

理想主義的花
終將盛開在浪漫主義的土壤里
我的熱情
永遠不會熄滅在現實主義的平凡里
我們終將上岸,陽光萬里

2. 大概的實現步驟概述

  1. 第一步:準備資料庫表
  • 使用t_act表(賬戶表)

  1. 第二步:IDEA中創建一個模塊,並引入依賴
      • spring-context
      • spring-jdbc
      • mysql驅動
      • mybatis
      • mybatis-spring:mybatis提供的與spring框架集成的依賴
      • 德魯伊連接池
      • junit
  1. 第三步:基於三層架構實現,所以提前創建好所有的包
      • com.powernode.bank.mapper
      • com.powernode.bank.service
      • com.powernode.bank.service.impl
      • com.powernode.bank.pojo
  1. 第四步:編寫pojo
  • Account,屬性私有化,提供公開的setter getter和toString。

  1. 第五步:編寫mapper介面
  • AccountMapper介面,定義方法

  1. 第六步:編寫mapper配置文件
  • 在配置文件中配置命名空間,以及每一個方法對應的sql。

  1. 第七步:編寫service介面和service介面實現類
      • AccountService
      • AccountServiceImpl
  1. 第八步:編寫jdbc.properties配置文件
  • 資料庫連接池相關信息

  1. 第九步:編寫mybatis-config.xml配置文件
      • 該文件可以沒有,大部分的配置可以轉移到spring配置文件中。
      • 如果遇到mybatis相關的系統級配置,還是需要這個文件。
  1. 第十步:編寫spring.xml配置文件
      • 組件掃描
      • 引入外部的屬性文件
      • 數據源
      • SqlSessionFactoryBean配置
        • 註入mybatis核心配置文件路徑
        • 指定別名包
        • 註入數據源
      • Mapper掃描配置器
        • 指定掃描的包
      • 事務管理器DataSourceTransactionManager
        • 註入數據源
      • 啟用事務註解
        • 註入事務管理器
  1. 第十一步:編寫測試程式,並添加事務,進行測試

3. 詳細實現操作步驟

具體實現內容:我們運用 Spring6 和 MyBatis 實現一個轉賬操作(該轉賬操作,進行一個事務上的控制,運用 MyBatis 執行 SQL 語句)。

  1. 第一步:準備資料庫表
  • 使用t_act表(賬戶表)

連接資料庫的工具有很多,這裡我們可以使用IDEA工具自帶的 DataBase 插件。可以根據下圖提示自行配置:

一般是在 IDEA 的左邊,DataBase

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

如下是 t_act 的表結構

在這裡插入圖片描述

如下是 t_act 的表數據內容:

在這裡插入圖片描述

  1. 第二步:IDEA中創建一個模塊,並引入依賴
      • spring-context
      • spring-jdbc
      • mysql驅動
      • mybatis
      • mybatis-spring:mybatis提供的與spring框架集成的依賴
      • 德魯伊連接池
      • junit

我們先在pom.xml 配置文件當中導入相關的 jar 包信息:

在這裡插入圖片描述

<?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.rainbowsea</groupId>
    <artifactId>spring6-016-mybaits</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <!--倉庫-->
    <repositories>
        <!--spring里程碑版本的倉庫-->
        <repository>
            <id>repository.spring.milestone</id>
            <name>Spring Milestone Repository</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>6.0.0-M2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>6.0.0-M2</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.30</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.11</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.7</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.13</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
  1. 第三步:基於三層架構實現,所以提前創建好所有的包
      • com.powernode.bank.mapper
      • com.powernode.bank.service
      • com.powernode.bank.service.impl
      • com.powernode.bank.pojo

在這裡插入圖片描述
在這裡插入圖片描述

  1. 第四步:編寫pojo
  • Account,屬性私有化,提供公開的setter getter和toString。

在這裡插入圖片描述

  1. 第五步:編寫mapper介面
  • AccountMapper介面,定義方法

在這裡插入圖片描述

package com.rainbowsea.bank.mapper;

import com.rainbowsea.bank.pojo.Account;

import java.util.List;

// 該介面的實現類不需要寫,是mybatis通過動態代理機制生成的實現類
public interface AccountMapper {

    // 這就是DAO,只要編寫CRUD方法即可

    /**
     * 新增賬戶
     * @param account
     * @return
     */
    int insert(Account account);


    /**
     * 根據賬戶刪除賬戶
     * @param actno
     * @return
     */
    int deleteByActno(String actno);


    /**
     * 根據賬戶更新
     * @param account
     * @return
     */
    int update(Account account);


    /**
     * 根據賬戶查詢賬戶
     * @param actno
     * @return
     */
    Account selectByActno(String actno);


    /**
     * 查詢所有的賬戶
     * @return
     */
    List<Account> selectAll();

}

  1. 第六步:編寫mapper配置文件
  • 在配置文件中配置命名空間,以及每一個方法對應的sql。

一定要註意,按照下圖提示創建這個目錄。註意是 斜杠(因為是創建目錄) 不是點兒。在resources目錄下新建。並且要和Mapper介面包對應上。因為只有這樣,MyBatis 才會進行動態代理這個介面。

同時:如果介面叫做AccountMapper,配置文件必須是 AccountMapper.xml,名稱要保持一致。

總結兩點:就是路徑位置要保持一致,對應的名稱也要保持一致。尾碼名不同。

在這裡插入圖片描述

在這裡插入圖片描述

同時在 AccountMapper.xml 當中編寫 SQL 語句內容。

在這裡插入圖片描述

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.rainbowsea.bank.mapper.AccountMapper">

    <insert id="insert">
        insert into t_act(actno,balance) values(#{actno}, #{balance})
    </insert>

    <delete id="deleteByActno">
        delete from t_act where actno = #{actno}
    </delete>

    <update id="update">
        update t_act set balance = #{balance} where actno = #{actno}
    </update>

    <select id="selectByActno" resultType="Account">
        select * from t_act where actno = #{actno}
    </select>

    <select id="selectAll" resultType="Account">
        select * from t_act
    </select>
</mapper>
  1. 第七步:編寫service介面和service介面實現類
      • AccountService
      • AccountServiceImpl

編寫 AccountService 業務介面,定義約束,規範,進行一個業務上的轉賬操作。

在這裡插入圖片描述

package com.rainbowsea.bank.service;

import com.rainbowsea.bank.pojo.Account;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


public interface AccountService {
    /**
     * 開戶
     * @param account
     * @return
     */
    int save(Account account);

    /**
     * 根據賬號銷戶
     * @param actno
     * @return
     */
    int deleteByActno(String actno);

    /**
     * 修改賬戶
     * @param act
     * @return
     */
    int update(Account act);

    /**
     * 根據賬號獲取賬戶
     * @param actno
     * @return
     */
    Account getByActno(String actno);

    /**
     * 獲取所有賬戶
     * @return
     */
    List<Account> getAll();

    /**
     * 轉賬
     * @param fromActno
     * @param toActno
     * @param money
     */
    void transfer(String fromActno, String toActno, double money);
}

註意:要將編寫的service實現類納入IoC容器管理,同時註意需要開啟事務@Transactional

在這裡插入圖片描述

在這裡插入圖片描述

package com.rainbowsea.bank.service.impl;

import com.rainbowsea.bank.mapper.AccountMapper;
import com.rainbowsea.bank.pojo.Account;
import com.rainbowsea.bank.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service(value = "accountServiceImpl")
@Transactional  // 放在類中,下麵的類中的所有方法都開啟了事務
public class AccountServiceImpl implements AccountService {

    // Could not find bean with name 'org.mybatis.spring.SqlSessionFactoryBean#0
    @Autowired // 非簡單類型自動裝配
    private AccountMapper accountMapper;
    @Override
    public int save(Account account) {
        return accountMapper.insert(account);
    }

    @Override
    public int deleteByActno(String actno) {
        return accountMapper.deleteByActno(actno);
    }

    @Override
    public int update(Account act) {
        return accountMapper.update(act);
    }

    @Override
    public Account getByActno(String actno) {
        return accountMapper.selectByActno(actno);
    }

    @Override
    public List<Account> getAll() {
        return accountMapper.selectAll();
    }

    @Override
    public void transfer(String fromActno, String toActno, double money) {
        Account fromAct = accountMapper.selectByActno(fromActno);

        if(fromAct.getBalance() < money) {
            throw new RuntimeException("餘額不足");
        }

        Account toAct = accountMapper.selectByActno(toActno);

        //模擬異常
      /*  String s = null;
        s.toString();
*/
        // 記憶體上修改
        fromAct.setBalance(fromAct.getBalance() - money);
        toAct.setBalance(toAct.getBalance() + money);

        // 資料庫上修改數據內容
        int count = accountMapper.update(fromAct);
        count += accountMapper.update(toAct);

        if(count != 2) {
            throw new RuntimeException("轉賬失敗");
        }


    }
}

  1. 第八步:在 resources 的根路徑下,編寫jdbc.properties配置文件
  • 資料庫連接池相關信息,賬號,密碼,同時註意要加上 jdbc, 同時註意不要加任何的空格,同時是 放在類的根路徑(resources )下

在這裡插入圖片描述

jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring6
jdbc.username=root
jdbc.password=MySQL123
  1. 第九步:編寫mybatis-config.xml配置文件
      • 該文件可以沒有,大部分的配置可以轉移到spring配置文件中。
      • 如果遇到mybatis相關的系統級配置,還是需要這個文件。
      • 放在類的根路徑(resources )下,只開啟日誌,其他配置到spring.xml中。

在這裡插入圖片描述
)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!--    幫助我們列印mybatis的日誌信息。sql語句等-->
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>

</configuration>
  1. 第十步:編寫spring.xml配置文件
      • 組件掃描
      • 引入外部的屬性文件
      • 數據源
      • SqlSessionFactoryBean配置
        • 註入mybatis核心配置文件路徑
        • 指定別名包
        • 註入數據源
      • Mapper掃描配置器
        • 指定掃描的包
      • 事務管理器DataSourceTransactionManager
        • 註入數據源
      • 啟用事務註解
        • 註入事務管理器
      • 同樣,我們還是將其防止到 類的根路徑下(resources )

註意:當你在spring.xml文件中直接寫標簽內容時,IDEA會自動給你添加命名空間

在這裡插入圖片描述

<?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
                           https://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.rainbowsea.bank"></context:component-scan>
    
    <!--    引入外部的屬性配置文件-->

    <context:property-placeholder location="jdbc.properties"></context:property-placeholder>

    <!--    數據源-->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="${jdbc.driver}"></property>
        <property name="url" value="${jdbc.url}"></property>
        <property name="username" value="${jdbc.username}"></property>
        <property name="password" value="${jdbc.password}"></property>
    </bean>

    <!--    配置SqlSessionFactoryBean  "org.mybatis.spring.SqlSessionFactoryBean"-->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
        <!--        註入數據源-->
        <property name="dataSource" ref="dataSource"></property>
        <!--        指定mybatis 核心配置文件-->
        <property name="configLocation" value="mybatis-config.xml"></property>
        <!--        指定別名-->
        <property name="typeAliasesPackage" value="com.rainbowsea.bank.pojo"></property>

    </bean>

    <!--    Mapper 掃描配置器,主要掃描Mapper 介面,生成代理類-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.rainbowsea.bank.mapper"></property>
    </bean>

    <!--    事務管理器-->
    <bean id="txManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!--        配置數據源-->
        <property name="dataSource" ref="dataSource"></property>
    </bean>

    <!--    啟用事務註解,事務管理器-->
    <tx:annotation-driven transaction-manager="txManger"></tx:annotation-driven>
</beans>
  1. 第十一步:編寫測試程式,並添加事務,進行測試

在這裡插入圖片描述
)

在這裡插入圖片描述

package com.rainbowsea.spring6.test;

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

public class SpringMybatisTest {

    @Test
    public void testSpringMybatis() {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring6.xml");
        // AccountService.class 左右兩邊保持一致性
        AccountService accountService = applicationContext.getBean("accountServiceImpl", AccountService.class);
        try {
            accountService.transfer("act-001","act-002",10000);
            System.out.println("轉賬成功");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}

沒有異常,看是否能轉賬成功

在這裡插入圖片描述

模擬異常,看是否,能夠進行正常的事務回滾

在這裡插入圖片描述

運行測試:

在這裡插入圖片描述

在這裡插入圖片描述


4. Spring配置文件的 import,導入外部xml 配置

如果 spring 配置文件有多個,可以在 spring 的核心配置文件中使用 import 進行引入,我們可以將組件掃描單獨定義到一個配置文件中,如下:我們將一個《組件掃描》,定義到一個單獨的名為common.xml的配置文件當中去,並導入,引入到 spring 的配置文件當中使用。如下:

在這裡插入圖片描述

使用<import> 標簽進行一個導入

在這裡插入圖片描述

<!--    在Spring 的核心配置文件中引入其他的子 spring 配置文件-->
    <import resource="common.xml"></import>

把模擬異常去了,測試,是否能夠轉賬成功。如下:

在這裡插入圖片描述

在這裡插入圖片描述

在這裡插入圖片描述

註意:在實際開發中,service 單獨配置到一個文件中,dao單獨配置到一個文件中,然後在核心配置文件中引入,養成好習慣。

5. 總結:

  1. Spring6 對集成MyBatis 開發:這裡總的來說是十步,完成的。

  2. 一定要註意,按照下圖提示創建這個目錄。註意是 斜杠(因為是創建目錄) 不是點兒。在resources目錄下新建。並且要和Mapper介面包對應上。因為只有這樣,MyBatis 才會進行動態代理這個介面。

    同時:如果介面叫做AccountMapper,配置文件必須是 AccountMapper.xml,名稱要保持一致。

    總結兩點:就是路徑位置要保持一致,對應的名稱也要保持一致。尾碼名不同。

  3. Spring 當中使用<import> 標簽導入外部xml 配置。

6. 最後:

“在這個最後的篇章中,我要表達我對每一位讀者的感激之情。你們的關註和回覆是我創作的動力源泉,我從你們身上吸取了無盡的靈感與勇氣。我會將你們的鼓勵留在心底,繼續在其他的領域奮鬥。感謝你們,我們總會在某個時刻再次相遇。”

在這裡插入圖片描述


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 前言 應用中的信息傳遞是為了實現各種功能和交互。信息傳遞可以幫助用戶和應用之間進行有效的溝通和交流。通過信息傳遞,應用可以向用戶傳遞重要的消息、通知和提示,以提供及時的反饋和指導。同時,用戶也可以通過信息傳遞嚮應用發送指令、請求和反饋,以實現個性化的需求和操作。 信息傳遞還可以幫助應用之間實現數 ...
  • Symbol 引用 iconfont icon圖標庫 Symbol 引用 這是一種全新的使用方式,應該說這才是未來的主流,也是平臺目前推薦的用法。相關介紹可以參考這篇文章 這種用法其實是做了一個 SVG 的集合,與另外兩種相比具有如下特點: 支持多色圖標了,不再受單色限制。 通過一些技巧,支持像字體 ...
  • XML中的字元串數據類型表示字元序列,包括換行、回車和製表符。處理器不修改值。`normalizedString`去除這些特殊字元,`token`則進一步移除前導和尾隨空格及多餘空格。字元串類型可使用枚舉、長度等限制。`date`和`dateTime`數據類型表示日期和時間,`duration`表示... ...
  • 一、是什麼 HMR全稱 Hot Module Replacement,可以理解為模塊熱替換,指在應用程式運行過程中,替換、添加、刪除模塊,而無需重新刷新整個應用 例如,我們在應用運行過程中修改了某個模塊,通過自動刷新會導致整個應用的整體刷新,那頁面中的狀態信息都會丟失 如果使用的是 HMR,就可以實 ...
  • theme: nico 寫在前面 主頁有更多其他篇章的方法,歡迎訪問查看。 本篇我們介紹radash中對象相關方法的使用和源碼解析。 assign:遞歸合併兩個對象 使用說明 功能說明:類似於 JavaScript 的 Object.assign 方法,用於將 override 對象的屬性和值複製到 ...
  • title: Vue 3 組件基礎與模板語法詳解 date: 2024/5/24 16:31:13 updated: 2024/5/24 16:31:13 categories: 前端開發 tags: Vue3特性 CompositionAPI Teleport Suspense Vue3安裝 組件 ...
  • 貪吃蛇作為一款極其經典且廣受歡迎的小游戲,是早期 Windows 電腦和功能手機(特別是諾基亞手機)流行度極高的小游戲,是當時功能手機時代最具代表性的游戲之一。游戲的基本規則和目標十分簡單,但卻極具吸引力,讓人欲罷不能。本博文我們用 Python 編寫屬於自己的貪吃蛇游戲,一起來體驗一下編程的樂趣與... ...
  • 當開發與Linux環境下MySQL資料庫交互的Java應用程式時,理解MySQL中的大小寫敏感性可以避免潛在的錯誤和問題。本指南深入探討了MySQL中的大小寫敏感設置,比較了5.7和8.0版本,併為Java開發者提供了最佳實踐。 1 理解MySQL中的大小寫敏感性 預設情況下,MySQL在Windo ...
一周排行
    -Advertisement-
    Play Games
  • 一:背景 1. 講故事 前些天有位朋友找到我,說他們的程式會偶發性的卡死一段時間,然後又好了,讓我幫忙看下怎麼回事?窗體類的程式解決起來相對來說比較簡單,讓朋友用procdump自動抓一個卡死時的dump,拿到dump之後,上 windbg 說話。 二:WinDbg 分析 1. 主線程在做什麼 要想 ...
  • 功能說明 使用ListView時,希望可以在單元格顯示圖片或其他控制項,發現原生的ListView不支持,於是通過拓展,實現ListView可以顯示任意控制項的功能,效果如下: 實現方法 本來想著在單元格裡面實現控制項的自繪的,但是沒找到辦法,最後是通過在單元格的錶面顯示對應控制項的,浮於錶面達到目的。 實 ...
  • 由於.NET Framework 4.0 是比較古老的版本,只有New Relic 7.0以下的版本才會支持.NET Framework 4.0的引用程式。 Technical support for .NET Framework 4.0 or lower 你可以參考這個官方Install New ...
  • 前言 隨著 DEV24.1.3 的發佈,XAF Blazor 中的屬性編輯器(PropertyEditor)也進行了很大的改動,在使用體驗上也更接近 WinForm 了,由於進行了大量的封裝,理解上沒有 WinForm 直觀,所以本文通過對屬性編輯器的原理進行解析,並對比新舊版本中的變化,使大家能夠 ...
  • OPC基金會提供了OPC UA .NET標準庫以及示常式序,但官方文檔過於簡單,光看官方文檔和示常式序很難弄懂OPC UA .NET標準庫怎麼用,花了不少時間摸索才略微弄懂如何使用,以下記錄如何從一個控制台程式開發一個OPC UA伺服器。 安裝Nuget包 安裝OPCFoundation.NetSt ...
  • 今天在技術群里,石頭哥向大家提了個問題:"如何在一個以System身份運行的.NET程式(Windows Services)中,以其它活動的用戶身份啟動可互動式進程(桌面應用程式、控制台程式、等帶有UI和互動式體驗的程式)"? 我以前有過類似的需求,是在GitLab流水線中運行帶有UI的自動化測試程 ...
  • .Net 中提供了一系列的管理對象集合的類型,數組、可變列表、字典等。從類型安全上集合分為兩類,泛型集合 和 非泛型集合,傳統的非泛型集合存儲為Object,需要類型轉。而泛型集合提供了更好的性能、編譯時類型安全,推薦使用。 ...
  • 在以前我做程式的時候,一般在登錄視窗裡面顯示程式名稱,登錄視窗一般設置一張背景圖片,由於程式的名稱一般都是確定的,所以也不存在太大的問題,不過如果客戶定製不同的系統的時候,需要使用Photoshop修改下圖層的文字,再生成圖片,然後替換一下也可以了。不過本著減少客戶使用繁瑣性,也可以使用空白名稱的通... ...
  • 一:背景 1. 講故事 在dump分析的過程中經常會看到很多線程卡在Monitor.Wait方法上,曾經也有不少人問我為什麼用 !syncblk 看不到 Monitor.Wait 上的鎖信息,剛好昨天有時間我就來研究一下。 二:Monitor.Wait 底層怎麼玩的 1. 案例演示 為了方便講述,先 ...
  • 目錄前言學習參考過程總結: 前言 做個自由仔。 學習參考 ChatGpt; https://www.cnblogs.com/zhili/p/DesignPatternSummery.html(大佬的,看了好多次) 過程 原由: 一開始只是想查查鏈式調用原理,以為是要繼承什麼介面,實現什麼方法才可以實 ...