mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
默认禁用 resilience4j 依赖,保证启动速度
This commit is contained in:
parent
1f327ef8ca
commit
08d39d4593
@ -31,6 +31,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.resilience4j</groupId>
|
<groupId>io.github.resilience4j</groupId>
|
||||||
<artifactId>resilience4j-spring-boot2</artifactId>
|
<artifactId>resilience4j-spring-boot2</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -55,13 +55,6 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 服务保障相关 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.resilience4j</groupId>
|
|
||||||
<artifactId>resilience4j-ratelimiter</artifactId>
|
|
||||||
<scope>provided</scope> <!-- 设置为 provided,主要是 GlobalExceptionHandler 使用 -->
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- xss -->
|
<!-- xss -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jsoup</groupId>
|
<groupId>org.jsoup</groupId>
|
||||||
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
|||||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
import io.github.resilience4j.ratelimiter.RequestNotPermitted;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
@ -33,6 +32,7 @@ import javax.validation.ConstraintViolationException;
|
|||||||
import javax.validation.ValidationException;
|
import javax.validation.ValidationException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*;
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.*;
|
||||||
|
|
||||||
@ -83,9 +83,6 @@ public class GlobalExceptionHandler {
|
|||||||
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
if (ex instanceof HttpRequestMethodNotSupportedException) {
|
||||||
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex);
|
||||||
}
|
}
|
||||||
if (ex instanceof RequestNotPermitted) {
|
|
||||||
return requestNotPermittedExceptionHandler(request, (RequestNotPermitted) ex);
|
|
||||||
}
|
|
||||||
if (ex instanceof ServiceException) {
|
if (ex instanceof ServiceException) {
|
||||||
return serviceExceptionHandler((ServiceException) ex);
|
return serviceExceptionHandler((ServiceException) ex);
|
||||||
}
|
}
|
||||||
@ -186,8 +183,7 @@ public class GlobalExceptionHandler {
|
|||||||
/**
|
/**
|
||||||
* 处理 Resilience4j 限流抛出的异常
|
* 处理 Resilience4j 限流抛出的异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = RequestNotPermitted.class)
|
public CommonResult<?> requestNotPermittedExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||||
public CommonResult<?> requestNotPermittedExceptionHandler(HttpServletRequest req, RequestNotPermitted ex) {
|
|
||||||
log.warn("[requestNotPermittedExceptionHandler][url({}) 访问过于频繁]", req.getRequestURL(), ex);
|
log.warn("[requestNotPermittedExceptionHandler][url({}) 访问过于频繁]", req.getRequestURL(), ex);
|
||||||
return CommonResult.error(TOO_MANY_REQUESTS);
|
return CommonResult.error(TOO_MANY_REQUESTS);
|
||||||
}
|
}
|
||||||
@ -226,7 +222,12 @@ public class GlobalExceptionHandler {
|
|||||||
return tableNotExistsResult;
|
return tableNotExistsResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 情况二:处理异常
|
// 情况二:部分特殊的库的处理
|
||||||
|
if (Objects.equals("io.github.resilience4j.ratelimiter.RequestNotPermitted", ex.getClass().getName())) {
|
||||||
|
return requestNotPermittedExceptionHandler(req, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 情况三:处理异常
|
||||||
log.error("[defaultExceptionHandler]", ex);
|
log.error("[defaultExceptionHandler]", ex);
|
||||||
// 插入异常日志
|
// 插入异常日志
|
||||||
this.createExceptionLog(req, ex);
|
this.createExceptionLog(req, ex);
|
||||||
|
Loading…
Reference in New Issue
Block a user