1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-25 02:27:10 +08:00

Merge pull request #2237 from 843294669/patch-1

Update spring-knowledge-and-questions-summary.md
This commit is contained in:
Guide 2024-01-09 19:16:11 +08:00 committed by GitHub
commit a549825034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -555,8 +555,8 @@ public class GlobalExceptionHandler {
### Spring 管理事务的方式有几种?
- **编程式事务**:在代码中硬编码(推荐使用) : 通过 `TransactionTemplate`或者 `TransactionManager` 手动管理事务,实际应用中很少使用,但是对于你理解 Spring 事务管理原理有帮助
- **声明式事务**:在 XML 配置文件中配置或者直接基于注解(推荐使用) : 实际是通过 AOP 实现(基于`@Transactional` 的全注解方式使用最多)
- **编程式事务**:在代码中硬编码(在分布式系统中推荐使用) : 通过 `TransactionTemplate`或者 `TransactionManager` 手动管理事务,事务范围过大会出现事务未提交导致超时,因此事务要比锁的粒度更小
- **声明式事务**:在 XML 配置文件中配置或者直接基于注解(单体应用或者简单业务系统推荐使用) : 实际是通过 AOP 实现(基于`@Transactional` 的全注解方式使用最多)
### Spring 事务中哪几种事务传播行为?