diff --git a/CHANGELOG.md b/CHANGELOG.md
index d79a863..8a3e1a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,3 +39,9 @@
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|:---|:---|:---|:---|:--|
| 1 | A | 基于 redis 实现的分布式锁策略 | 2022-12-7 14:45:40 | |
+
+# release_1.1.0
+
+| 序号 | 变更类型 | 说明 | 时间 | 备注 |
+|:---|:---|:---|:---|:--|
+| 1 | A | 整合 spring | 2022-12-7 14:45:40 | |
diff --git a/README.md b/README.md
index ce902fc..6fdc148 100644
--- a/README.md
+++ b/README.md
@@ -10,9 +10,13 @@
- 基于 redis 的分布式锁
-- 基于 oracle 的分布式锁
+- 整合 spring
-- 基于 mysql 的分布式锁
+- 整合 spring-boot
+
+- 开箱即用,支持注解。
+
+- 支持多种 redis 的声明方式
# 变更日志
@@ -32,7 +36,7 @@ maven 3.x+
com.github.houbb
lock-core
- 1.0.0
+ 1.1.0
```
@@ -57,21 +61,108 @@ try {
}
```
+# 整合 spring
+
+## maven 引入
+
+```xml
+
+ com.github.houbb
+ lock-spring
+ 1.1.0
+
+```
+
+## 指定 bean 使用
+
+### 启用分布式锁
+
+`@EnableLock` 启用分布式锁。
+
+```xml
+@Configurable
+@ComponentScan(basePackages = "com.github.houbb.lock.test.service")
+@EnableLock
+public class SpringConfig {
+}
+```
+
+### 使用 LockBs
+
+我们可以直接 `LockBs` 的引导类。
+
+```java
+@ContextConfiguration(classes = SpringConfig.class)
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SpringServiceRawTest {
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private LockBs lockBs;
+
+ @Test
+ public void queryLogTest() {
+ final String key = "name";
+ try {
+ lockBs.tryLock(key);
+ final String value = userService.rawUserName(1L);
+ } catch (Exception exception) {
+ throw new RuntimeException(exception);
+ } finally {
+ lockBs.unlock(key);
+ }
+ }
+
+}
+```
+
+## aop 注解使用
+
+### 指定方法注解
+
+当然,我们可以在方法上直接指定注解 `@Lock`,使用更加方便。
+
+支持 SPEL 表达式。
+
+```java
+@Service
+public class UserService {
+
+ @Lock
+ public String queryUserName(Long userId) {
+ }
+
+ @Lock(value = "#user.name")
+ public void queryUserName2(User user) {
+ }
+}
+```
+
+直接使用,AOP 切面生效即可。
+
+# springboot 整合
+
+## maven 引入
+
+```xml
+
+ com.github.houbb
+ lock-springboot-starter
+ 1.1.0
+
+```
+
+## 使用
+
+同 spring
+
# 后期 Road-MAP
- [ ] 支持锁的可重入
持有锁的线程可以多次获取锁
-- [ ] redis 实现的支持
-
-cluster 支持
-
-redis 支持
-
-aliyun-redis 支持
-
-各种各样的声明方式的默认支持
-
-- [ ] 分布式锁注解支持
+- [x] 分布式锁注解支持
diff --git a/lock-api/pom.xml b/lock-api/pom.xml
index 950d664..569f85e 100644
--- a/lock-api/pom.xml
+++ b/lock-api/pom.xml
@@ -5,7 +5,7 @@
lock
com.github.houbb
- 1.0.0
+ 1.1.0
4.0.0
diff --git a/lock-core/pom.xml b/lock-core/pom.xml
index c110f78..5410446 100644
--- a/lock-core/pom.xml
+++ b/lock-core/pom.xml
@@ -5,7 +5,7 @@
lock
com.github.houbb
- 1.0.0
+ 1.1.0
4.0.0
diff --git a/lock-core/src/main/java/com/github/houbb/lock/core/support/lock/RedisLockSupport.java b/lock-core/src/main/java/com/github/houbb/lock/core/support/lock/RedisLockSupport.java
index 89c4db8..1a8a307 100644
--- a/lock-core/src/main/java/com/github/houbb/lock/core/support/lock/RedisLockSupport.java
+++ b/lock-core/src/main/java/com/github/houbb/lock/core/support/lock/RedisLockSupport.java
@@ -57,31 +57,29 @@ public class RedisLockSupport implements ILockSupport {
@Override
public boolean tryLock(String key, ILockSupportContext context) {
- log.info("开始尝试获取锁 {}", key);
-
// 生成当前线程的唯一标识
Id id = context.id();
final String requestId = id.id();
IdThreadLocalHelper.put(requestId);
- log.info("开始尝试获取锁 requestId: {}", requestId);
+ log.info("[LOCK] BEGIN TRY LOCK key: {} requestId: {}", key, requestId);
final ICommonCacheService commonCacheService = context.cache();
-
final int lockExpireMills = context.lockExpireMills();
String result = commonCacheService.set(key, requestId, JedisConst.SET_IF_NOT_EXIST, JedisConst.SET_WITH_EXPIRE_TIME, lockExpireMills);
+ log.info("[LOCK] END TRY LOCK key: {}, requestId: {}, result: {}", key, requestId, result);
return JedisConst.OK.equalsIgnoreCase(result);
}
@Override
public boolean unlock(String key, ILockSupportContext context) {
- log.info("开始尝试释放锁 {}", key);
String requestId = IdThreadLocalHelper.get();
- log.info("开始尝试释放锁 requestId: {}", requestId);
+ log.info("[LOCK] BEGIN UN LOCK key: {} requestId: {}", key, requestId);
final ICommonCacheService commonCacheService = context.cache();
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
Object result = commonCacheService.eval(script, Collections.singletonList(key), Collections.singletonList(requestId));
+ log.info("[LOCK] END UN LOCK key: {}, requestId: {}, result: {}", key, requestId, result);
return JedisConst.RELEASE_SUCCESS.equals(result);
}
diff --git a/lock-spring/pom.xml b/lock-spring/pom.xml
index b21886e..f009ca8 100644
--- a/lock-spring/pom.xml
+++ b/lock-spring/pom.xml
@@ -5,7 +5,7 @@
lock
com.github.houbb
- 1.0.0
+ 1.1.0
4.0.0
@@ -25,6 +25,11 @@
com.github.houbb
aop-spring
+
+
+ com.github.houbb
+ redis-config-spring
+
-
\ No newline at end of file
+
diff --git a/lock-spring/src/main/java/com/github/houbb/lock/spring/annotation/EnableLock.java b/lock-spring/src/main/java/com/github/houbb/lock/spring/annotation/EnableLock.java
index 82d8b3c..e4ae0d5 100644
--- a/lock-spring/src/main/java/com/github/houbb/lock/spring/annotation/EnableLock.java
+++ b/lock-spring/src/main/java/com/github/houbb/lock/spring/annotation/EnableLock.java
@@ -34,10 +34,13 @@ public @interface EnableLock {
/**
* 缓存实现策略 bean 名称
+ *
+ * 默认引入 redis-config 中的配置
+ *
* @return 实现
* @since 1.1.0
*/
- String cache() default "lockCache";
+ String cache() default "springRedisService";
}
diff --git a/lock-spring/src/main/java/com/github/houbb/lock/spring/aop/LockAspect.java b/lock-spring/src/main/java/com/github/houbb/lock/spring/aop/LockAspect.java
index 0ca7da6..6086faa 100644
--- a/lock-spring/src/main/java/com/github/houbb/lock/spring/aop/LockAspect.java
+++ b/lock-spring/src/main/java/com/github/houbb/lock/spring/aop/LockAspect.java
@@ -3,7 +3,6 @@ package com.github.houbb.lock.spring.aop;
import com.github.houbb.aop.spring.util.SpringAopUtil;
import com.github.houbb.heaven.util.lang.ObjectUtil;
import com.github.houbb.heaven.util.lang.StringUtil;
-import com.github.houbb.heaven.util.lang.reflect.ReflectMethodUtil;
import com.github.houbb.heaven.util.util.ArrayUtil;
import com.github.houbb.lock.api.exception.LockException;
import com.github.houbb.lock.core.bs.LockBs;
@@ -11,9 +10,11 @@ import com.github.houbb.lock.spring.annotation.Lock;
import com.github.houbb.log.integration.core.Log;
import com.github.houbb.log.integration.core.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.expression.EvaluationContext;
@@ -23,8 +24,8 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
import java.util.Arrays;
-import java.util.List;
import java.util.concurrent.TimeUnit;
/**
@@ -63,15 +64,16 @@ public class LockAspect {
Lock lock = method.getAnnotation(Lock.class);
// 如果构建 key?
- Object[] args = point.getArgs();
- String lockKey = buildLockKey(lock, method, args);
+ String lockKey = buildLockKey(lock, point);
+
+ boolean tryLockFlag = false;
try {
long tryLockMills = lock.tryLockMills();
- boolean tryLockFlag = lockBs.tryLock(tryLockMills, TimeUnit.MILLISECONDS, lockKey);
+ tryLockFlag = lockBs.tryLock(tryLockMills, TimeUnit.MILLISECONDS, lockKey);
if(!tryLockFlag) {
- log.warn("尝试获取锁失败 {}", lockKey);
- throw new LockException("尝试获取锁失败 " + lockKey);
+ log.warn("[LOCK] TRY LOCK FAILED {}", lockKey);
+ throw new LockException("[LOCK] TRY LOCK FAILED " + lockKey);
}
// 执行业务
@@ -79,10 +81,10 @@ public class LockAspect {
} catch (Throwable e) {
throw new RuntimeException(e);
} finally {
- boolean unLockFlag = lockBs.unlock(lockKey);
- if(!unLockFlag) {
- log.warn("尝试释放锁失败 {}", lockKey);
- // 这里释放异常,没有意义。
+ // 只有获取锁的情况下,才尝试释放锁
+ if(tryLockFlag) {
+ boolean unLockFlag = lockBs.unlock(lockKey);
+ // 异常处理等
}
}
} else {
@@ -97,19 +99,19 @@ public class LockAspect {
*
* https://www.cnblogs.com/best/p/5748105.html SpEL
* @param lock 注解信息
- * @param args 参数
+ * @param joinPoint 参数
* @return 结果
*/
private String buildLockKey(Lock lock,
- Method method,
- Object[] args) {
+ ProceedingJoinPoint joinPoint) {
+ final Object[] args = joinPoint.getArgs();
final String lockValue = lock.value();
//创建SpEL表达式的解析器
ExpressionParser parser = new SpelExpressionParser();
//1. 如果没有入参怎么办?
if(ArrayUtil.isEmpty(args)) {
- log.warn("对应的数组信息为空,直接返回 key 的值 {}", lockValue);
+ log.warn("[LOCK] method args is empty, return lock.value() {}", lockValue);
return lockValue;
}
@@ -123,10 +125,14 @@ public class LockAspect {
//解析表达式需要的上下文,解析时有一个默认的上下文
// jdk1.7 之前,直接使用 arg0, arg1...
EvaluationContext ctx = new StandardEvaluationContext();
- List paramNameList = ReflectMethodUtil.getParamNames(method);
- for(int i = 0; i < paramNameList.size(); i++) {
- String paramName = paramNameList.get(i);
+ // 利用 spring 的处理方式
+ Signature signature = joinPoint.getSignature();
+ MethodSignature methodSignature = (MethodSignature) signature;
+ String[] paramNameList = methodSignature.getParameterNames();
+
+ for(int i = 0; i < paramNameList.length; i++) {
+ String paramName = paramNameList[i];
Object paramValue = args[i];
//在上下文中设置变量,变量名为user,内容为user对象
diff --git a/lock-spring/src/main/java/com/github/houbb/lock/spring/config/CommonCacheConfig.java b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/CommonCacheConfig.java
new file mode 100644
index 0000000..cf20156
--- /dev/null
+++ b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/CommonCacheConfig.java
@@ -0,0 +1,16 @@
+package com.github.houbb.lock.spring.config;
+
+import com.github.houbb.redis.config.spring.annotation.EnableRedisConfig;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * bean 配置
+ *
+ * @author binbin.hou
+ * @since 0.0.2
+ */
+@Configuration
+@EnableRedisConfig
+public class CommonCacheConfig {
+
+}
diff --git a/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockAopConfig.java b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockAopConfig.java
index eea50d9..8cb4820 100644
--- a/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockAopConfig.java
+++ b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockAopConfig.java
@@ -23,7 +23,7 @@ import org.springframework.core.type.AnnotationMetadata;
*/
@Configuration
@ComponentScan(basePackages = "com.github.houbb.lock.spring")
-@Import(LockBeanConfig.class)
+@Import({LockBeanConfig.class, CommonCacheConfig.class})
public class LockAopConfig implements ImportAware, BeanFactoryPostProcessor {
@Bean("lockBs")
diff --git a/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockBeanConfig.java b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockBeanConfig.java
index b7b3e91..65651ad 100644
--- a/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockBeanConfig.java
+++ b/lock-spring/src/main/java/com/github/houbb/lock/spring/config/LockBeanConfig.java
@@ -1,11 +1,7 @@
package com.github.houbb.lock.spring.config;
-import com.github.houbb.common.cache.api.service.ICommonCacheService;
-import com.github.houbb.heaven.util.lang.StringUtil;
import com.github.houbb.id.api.Id;
import com.github.houbb.id.core.core.Ids;
-import com.github.houbb.redis.config.core.factory.JedisRedisServiceFactory;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -20,24 +16,6 @@ import org.springframework.context.annotation.Configuration;
@ComponentScan(basePackages = "com.github.houbb.lock.spring")
public class LockBeanConfig {
- @Value("${redis.address:127.0.0.1}")
- private String redisAddress;
-
- @Value("${redis.port:6379}")
- private int redisPort;
-
- @Value("${redis.password:}")
- private String redisPassword;
-
- @Bean("lockCache")
- public ICommonCacheService lockCache() {
- if(StringUtil.isNotEmpty(redisPassword)) {
- return JedisRedisServiceFactory.pooled(redisAddress, redisPort, redisPassword);
- }
-
- return JedisRedisServiceFactory.simple(redisAddress, redisPort);
- }
-
@Bean("lockId")
public Id lockId() {
return Ids.uuid32();
diff --git a/lock-springboot-starter/pom.xml b/lock-springboot-starter/pom.xml
new file mode 100644
index 0000000..3445b1f
--- /dev/null
+++ b/lock-springboot-starter/pom.xml
@@ -0,0 +1,25 @@
+
+
+
+ lock
+ com.github.houbb
+ 1.1.0
+
+ 4.0.0
+
+ lock-springboot-starter
+
+
+
+ com.github.houbb
+ lock-spring
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
diff --git a/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/config/LockAutoConfig.java b/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/config/LockAutoConfig.java
new file mode 100644
index 0000000..904fb4a
--- /dev/null
+++ b/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/config/LockAutoConfig.java
@@ -0,0 +1,18 @@
+package com.github.houbb.lock.springboot.starter.config;
+
+import com.github.houbb.lock.spring.annotation.EnableLock;
+import com.github.houbb.lock.spring.config.LockAopConfig;
+import com.github.houbb.redis.config.spring.annotation.EnableRedisConfig;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 分布式锁自动配置
+ * @author binbin.hou
+ * @since 1.0.0
+ */
+@Configuration
+@ConditionalOnClass(LockAutoConfig.class)
+@EnableLock
+public class LockAutoConfig {
+}
diff --git a/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/package-info.java b/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/package-info.java
new file mode 100644
index 0000000..83e0666
--- /dev/null
+++ b/lock-springboot-starter/src/main/java/com/github/houbb/lock/springboot/starter/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * @author d
+ * @since 1.0.0
+ */
+package com.github.houbb.lock.springboot.starter;
diff --git a/lock-springboot-starter/src/main/resources/META-INF/spring.factories b/lock-springboot-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..ba45fb7
--- /dev/null
+++ b/lock-springboot-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.github.houbb.lock.springboot.starter.config.LockAutoConfig
diff --git a/lock-test/pom.xml b/lock-test/pom.xml
index f4ad931..c4320bb 100644
--- a/lock-test/pom.xml
+++ b/lock-test/pom.xml
@@ -5,7 +5,7 @@
lock
com.github.houbb
- 1.0.0
+ 1.1.0
4.0.0
@@ -30,6 +30,23 @@
com.github.houbb
test-spring
+
+
+ com.github.houbb
+ slf4j-common
+ 1.0.0
+ true
+
+
+ ch.qos.logback
+ logback-core
+ 1.1.11
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.11
+
diff --git a/lock-test/src/main/java/com/github/houbb/lock/test/service/UserService.java b/lock-test/src/main/java/com/github/houbb/lock/test/service/UserService.java
index 8cd3225..b3c3f21 100644
--- a/lock-test/src/main/java/com/github/houbb/lock/test/service/UserService.java
+++ b/lock-test/src/main/java/com/github/houbb/lock/test/service/UserService.java
@@ -11,12 +11,16 @@ import org.springframework.stereotype.Service;
@Service
public class UserService {
+ public String rawUserName(Long userId) {
+ return userId+"-name";
+ }
+
@Lock
public String queryUserName(Long userId) {
return userId+"-name";
}
- @Lock(value = "#arg0.name")
+ @Lock(value = "#user.name")
public void queryUserName2(User user) {
System.out.println("user: " + user.toString());
}
diff --git a/lock-test/src/test/java/com/github/houbb/lock/test/spring/SpringServiceRawTest.java b/lock-test/src/test/java/com/github/houbb/lock/test/spring/SpringServiceRawTest.java
new file mode 100644
index 0000000..4bc21e0
--- /dev/null
+++ b/lock-test/src/test/java/com/github/houbb/lock/test/spring/SpringServiceRawTest.java
@@ -0,0 +1,41 @@
+package com.github.houbb.lock.test.spring;
+
+
+import com.github.houbb.lock.core.bs.LockBs;
+import com.github.houbb.lock.test.config.SpringConfig;
+import com.github.houbb.lock.test.model.User;
+import com.github.houbb.lock.test.service.UserService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author binbin.hou
+ * @since 1.0.0
+ */
+@ContextConfiguration(classes = SpringConfig.class)
+@RunWith(SpringJUnit4ClassRunner.class)
+public class SpringServiceRawTest {
+
+ @Autowired
+ private UserService userService;
+
+ @Autowired
+ private LockBs lockBs;
+
+ @Test
+ public void queryLogTest() {
+ final String key = "name";
+ try {
+ lockBs.tryLock(key);
+ final String value = userService.rawUserName(1L);
+ } catch (Exception exception) {
+ throw new RuntimeException(exception);
+ } finally {
+ lockBs.unlock(key);
+ }
+ }
+
+}
diff --git a/lock-test/src/test/resources/logback.xml b/lock-test/src/test/resources/logback.xml
new file mode 100644
index 0000000..2dc2b5a
--- /dev/null
+++ b/lock-test/src/test/resources/logback.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ utf-8
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lock-test2/pom.xml b/lock-test2/pom.xml
new file mode 100644
index 0000000..9e16f5a
--- /dev/null
+++ b/lock-test2/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+ lock
+ com.github.houbb
+ 1.1.0
+
+ 4.0.0
+
+ lock-test2
+
+
+
+ com.github.houbb
+ lock-springboot-starter
+
+
+
+ junit
+ junit
+
+
+
+ com.github.houbb
+ test-spring
+
+
+
+ com.github.houbb
+ slf4j-common
+ 1.0.0
+ true
+
+
+ ch.qos.logback
+ logback-core
+ 1.1.11
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.11
+
+
+
diff --git a/lock-test2/src/main/java/com/github/houbb/lock/test2/package-info.java b/lock-test2/src/main/java/com/github/houbb/lock/test2/package-info.java
new file mode 100644
index 0000000..dba4562
--- /dev/null
+++ b/lock-test2/src/main/java/com/github/houbb/lock/test2/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * @author d
+ * @since 1.0.0
+ */
+package com.github.houbb.lock.test2;
diff --git a/lock-test2/src/main/java/com/github/houbb/lock/test2/service/MyApplication.java b/lock-test2/src/main/java/com/github/houbb/lock/test2/service/MyApplication.java
new file mode 100644
index 0000000..7f33e4d
--- /dev/null
+++ b/lock-test2/src/main/java/com/github/houbb/lock/test2/service/MyApplication.java
@@ -0,0 +1,17 @@
+package com.github.houbb.lock.test2.service;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author binbin.hou
+ * @since 0.0.3
+ */
+@SpringBootApplication
+public class MyApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MyApplication.class, args);
+ }
+
+}
diff --git a/lock-test2/src/main/java/com/github/houbb/lock/test2/service/UserService.java b/lock-test2/src/main/java/com/github/houbb/lock/test2/service/UserService.java
new file mode 100644
index 0000000..b763d12
--- /dev/null
+++ b/lock-test2/src/main/java/com/github/houbb/lock/test2/service/UserService.java
@@ -0,0 +1,18 @@
+package com.github.houbb.lock.test2.service;
+
+import com.github.houbb.lock.spring.annotation.Lock;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author binbin.hou
+ * @since 0.0.1
+ */
+@Service
+public class UserService {
+
+ @Lock
+ public void queryInfo(final String id) {
+ System.out.println("query info: " + id);
+ }
+
+}
diff --git a/lock-test2/src/test/java/com/github/houbb/lock/test2/service/UserServiceTest.java b/lock-test2/src/test/java/com/github/houbb/lock/test2/service/UserServiceTest.java
new file mode 100644
index 0000000..1ccbeff
--- /dev/null
+++ b/lock-test2/src/test/java/com/github/houbb/lock/test2/service/UserServiceTest.java
@@ -0,0 +1,25 @@
+package com.github.houbb.lock.test2.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author binbin.hou
+ * @since 0.0.2
+ */
+@ContextConfiguration(classes = MyApplication.class)
+@RunWith(SpringJUnit4ClassRunner.class)
+public class UserServiceTest {
+
+ @Autowired
+ private UserService service;
+
+ @Test
+ public void queryTest() {
+ service.queryInfo("1");
+ }
+
+}
diff --git a/lock-test2/src/test/java/com/github/houbb/lock/test2/service/package-info.java b/lock-test2/src/test/java/com/github/houbb/lock/test2/service/package-info.java
new file mode 100644
index 0000000..fcbf8d0
--- /dev/null
+++ b/lock-test2/src/test/java/com/github/houbb/lock/test2/service/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * @author d
+ * @since 1.0.0
+ */
+package com.github.houbb.lock.test2.service;
diff --git a/pom.xml b/pom.xml
index 19178ad..67e2362 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,12 +5,14 @@
com.github.houbb
lock
pom
- 1.0.0
+ 1.1.0
lock-api
lock-core
lock-test
lock-spring
+ lock-springboot-starter
+ lock-test2
@@ -46,7 +48,7 @@
4.12
- 2.8.1
+ 1.5.22.RELEASE
@@ -67,6 +69,11 @@
lock-spring
${project.version}
+
+ com.github.houbb
+ lock-springboot-starter
+ ${project.version}
+
@@ -111,6 +118,11 @@
redis-config-core
${redis-config.version}
+
+ com.github.houbb
+ redis-config-spring
+ ${redis-config.version}
+
@@ -121,12 +133,6 @@
test
-
- redis.clients
- jedis
- ${jedis.version}
-
-
com.github.houbb
aop-core
@@ -144,6 +150,12 @@
${test.version}
+
+ org.springframework.boot
+ spring-boot-starter
+ ${spring-boot.version}
+
+
diff --git a/release.bat b/release.bat
index 1574b8c..9bfc540 100644
--- a/release.bat
+++ b/release.bat
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
:: 版本号信息(需要手动指定)
:::: 旧版本名称
-SET version=1.0.0
+SET version=1.1.0
:::: 新版本名称
-SET newVersion=1.1.0
+SET newVersion=1.2.0
:::: 组织名称
SET groupName=com.github.houbb
:::: 项目名称