From d7a1562f0b3a7e3784472aa59ca9c85f3202f3ca Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 3 Aug 2025 19:43:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E3=80=90framework=20=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E3=80=91GlobalExceptionHandler=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=20guava=20UncheckedExecutionException=20=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=EF=BC=8Chttps://t.zsxq.com/UszdH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/handler/GlobalExceptionHandler.java | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java index 22234ba3b..491474c3c 100644 --- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java +++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java @@ -17,10 +17,6 @@ import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.google.common.util.concurrent.UncheckedExecutionException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.ConstraintViolation; -import jakarta.validation.ConstraintViolationException; -import jakarta.validation.ValidationException; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -37,8 +33,11 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import org.springframework.web.servlet.NoHandlerFoundException; -import org.springframework.web.servlet.resource.NoResourceFoundException; +import javax.servlet.http.HttpServletRequest; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.ValidationException; import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -96,9 +95,6 @@ public class GlobalExceptionHandler { if (ex instanceof NoHandlerFoundException) { return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex); } - if (ex instanceof NoResourceFoundException) { - return noResourceFoundExceptionHandler(request, (NoResourceFoundException) ex); - } if (ex instanceof HttpRequestMethodNotSupportedException) { return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex); } @@ -226,15 +222,6 @@ public class GlobalExceptionHandler { return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL())); } - /** - * 处理 SpringMVC 请求地址不存在 - */ - @ExceptionHandler(NoResourceFoundException.class) - private CommonResult noResourceFoundExceptionHandler(HttpServletRequest req, NoResourceFoundException ex) { - log.warn("[noResourceFoundExceptionHandler]", ex); - return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getResourcePath())); - } - /** * 处理 SpringMVC 请求方法不正确 *