# lock-starter **Repository Path**: qq595717019/lock-starter ## Basic Information - **Project Name**: lock-starter - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-21 - **Last Updated**: 2025-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Lock Starter 一个基于 Redis 的分布式锁 Spring Boot Starter 实现。 ## 功能特性 - 支持基于 Redis 的分布式锁 - 提供 `@AntiResubmit` 注解,防止重复提交 - 支持自定义锁超时时间和等待时间 - 支持多种参数类型的重复提交判断 ## 快速开始 ### 1. 添加依赖 ```xml com.tre.framework lock-starter 0.0.1-SNAPSHOT ``` ### 2. 配置 Redis 在 `application.properties` 或 `application.yml` 中配置 Redis: ```properties spring.redis.host=localhost spring.redis.port=6379 spring.redis.password=123456 spring.redis.database=0 ``` ### 3. 使用注解 ```java @RestController @RequestMapping("/api") public class TestController { @AntiResubmit(key = "#request.id") @PostMapping("/submit") public String submit(@RequestBody TestRequest request) { return "success"; } } ``` ## 注解参数说明 - `key`: SpEL 表达式,用于生成锁的键值 - `timeout`: 锁的超时时间(毫秒),默认 5000ms - `waitTime`: 获取锁的等待时间(毫秒),默认 0ms ## 测试说明 项目包含完整的单元测试,涵盖以下场景: 1. GET 请求参数防重复提交 2. 请求头参数防重复提交 3. 表单参数防重复提交 4. JSON 请求体防重复提交 5. 组合参数防重复提交 运行测试: ```bash mvn clean test ``` ## 注意事项 1. 确保 Redis 服务可用且配置正确 2. SpEL 表达式需要根据实际参数进行配置 3. 合理设置超时时间和等待时间