在做支付相关的功能时,会大量的使用到锁的概念.为了以后方便扩展这里采用了分布式锁,而放弃使用内存锁.
在支付系统中用到锁的功能基本为:操作余额,接收支付回调处理订单时,结算等
该文中使用的锁,采用的是相对流行redission进行锁的操作.
- 引入redission
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.16.8</version>
</dependency>
- 配置application.yml(具体配置根据实际情况)