diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java index bd68884..7140721 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/exception/JeecgBootExceptionHandler.java @@ -38,6 +38,15 @@ public class JeecgBootExceptionHandler { } /** + * 处理自定义微服务异常 + */ + @ExceptionHandler(JeecgCloudException.class) + public Result<?> handleJeecgCloudException(JeecgCloudException e){ + log.error(e.getMessage(), e); + return Result.error(e.getMessage()); + } + + /** * 处理自定义异常 */ @ExceptionHandler(JeecgBoot401Exception.class) diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-tools/src/main/java/org/jeecg/common/exception/JeecgCloudException.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-tools/src/main/java/org/jeecg/common/exception/JeecgCloudException.java new file mode 100644 index 0000000..b7623ae --- /dev/null +++ b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-tools/src/main/java/org/jeecg/common/exception/JeecgCloudException.java @@ -0,0 +1,15 @@ +package org.jeecg.common.exception; + +/** + * @Description: jeecg-cloud自定义异常 + * @Author: zyf + * @Date: 2022-05-30 + */ +public class JeecgCloudException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public JeecgCloudException(String message) { + super(message); + } + +} diff --git a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/pom.xml b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/pom.xml index 88777c0..1fc3029 100644 --- a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/pom.xml +++ b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/pom.xml @@ -12,6 +12,10 @@ <description>jeecg-boot-starter-分布式锁</description> <dependencies> <dependency> + <groupId>org.jeecgframework.boot</groupId> + <artifactId>jeecg-boot-base-tools</artifactId> + </dependency> + <dependency> <groupId>org.redisson</groupId> <artifactId>redisson</artifactId> </dependency> diff --git a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/src/main/java/org/jeecg/boot/starter/lock/aspect/RepeatSubmitAspect.java b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/src/main/java/org/jeecg/boot/starter/lock/aspect/RepeatSubmitAspect.java index 0225ce4..d7eb932 100644 --- a/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/src/main/java/org/jeecg/boot/starter/lock/aspect/RepeatSubmitAspect.java +++ b/jeecg-boot/jeecg-boot-starter/jeecg-boot-starter-lock/src/main/java/org/jeecg/boot/starter/lock/aspect/RepeatSubmitAspect.java @@ -11,6 +11,7 @@ import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.jeecg.boot.starter.lock.annotation.JRepeat; import org.jeecg.boot.starter.lock.client.RedissonLockClient; +import org.jeecg.common.exception.JeecgCloudException; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.stereotype.Component; @@ -63,7 +64,7 @@ public class RepeatSubmitAspect extends BaseAspect{ return joinPoint.proceed(); } else { // 未获取到锁 - throw new Exception("请勿重复提交"); + throw new JeecgCloudException("请勿重复提交"); } } finally { // 如果锁还存在,在方法执行完成后,释放锁