diff --git a/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeCloudAutoConfiguration.java b/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeCloudAutoConfiguration.java index cd9ac77..01c37de 100644 --- a/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeCloudAutoConfiguration.java +++ b/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeCloudAutoConfiguration.java @@ -16,7 +16,7 @@ package org.springblade.core.cloud.config; import com.alibaba.cloud.sentinel.feign.SentinelFeignAutoConfiguration; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler; import feign.Feign; import feign.RequestInterceptor; import org.springblade.core.cloud.feign.BladeFeignSentinel; diff --git a/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeSentinelFilterConfiguration.java b/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeSentinelFilterConfiguration.java index 95f4981..d99e543 100644 --- a/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeSentinelFilterConfiguration.java +++ b/blade-core-cloud/src/main/java/org/springblade/core/cloud/config/BladeSentinelFilterConfiguration.java @@ -16,12 +16,12 @@ package org.springblade.core.cloud.config; import com.alibaba.cloud.sentinel.SentinelProperties; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.SentinelWebInterceptor; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.DefaultBlockExceptionHandler; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.UrlCleaner; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.config.SentinelWebMvcConfig; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.SentinelWebInterceptor; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.DefaultBlockExceptionHandler; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.RequestOriginParser; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.config.SentinelWebMvcConfig; +import com.alibaba.csp.sentinel.adapter.web.common.UrlCleaner; import lombok.RequiredArgsConstructor; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Bean; @@ -56,7 +56,7 @@ public class BladeSentinelFilterConfiguration { } else { if (StringUtils.hasText(properties.getBlockPage())) { sentinelWebMvcConfig.setBlockExceptionHandler( - ((request, response, e) -> response.sendRedirect(properties.getBlockPage()))); + ((request, response, s, e) -> response.sendRedirect(properties.getBlockPage()))); } else { sentinelWebMvcConfig.setBlockExceptionHandler(new DefaultBlockExceptionHandler()); } diff --git a/blade-core-cloud/src/main/java/org/springblade/core/cloud/sentinel/BladeBlockExceptionHandler.java b/blade-core-cloud/src/main/java/org/springblade/core/cloud/sentinel/BladeBlockExceptionHandler.java index 159373c..ae314b1 100644 --- a/blade-core-cloud/src/main/java/org/springblade/core/cloud/sentinel/BladeBlockExceptionHandler.java +++ b/blade-core-cloud/src/main/java/org/springblade/core/cloud/sentinel/BladeBlockExceptionHandler.java @@ -1,15 +1,14 @@ package org.springblade.core.cloud.sentinel; -import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler; +import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler; import com.alibaba.csp.sentinel.slots.block.BlockException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springblade.core.tool.api.R; import org.springblade.core.tool.jackson.JsonUtil; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - /** * Sentinel统一限流策略 * @@ -17,7 +16,7 @@ import jakarta.servlet.http.HttpServletResponse; */ public class BladeBlockExceptionHandler implements BlockExceptionHandler { @Override - public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception { + public void handle(HttpServletRequest request, HttpServletResponse response, String s, BlockException e) throws Exception { // Return 429 (Too Many Requests) by default. response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value()); response.setContentType(MediaType.APPLICATION_JSON_VALUE);