this Fixes  Fixes
package org.springframework.cloud.alibaba.sentinel.custom;
+import java.util.Optional;
+
+import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
+import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
+import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
+import com.alibaba.csp.sentinel.init.InitExecutor;
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
import com.alibaba.csp.sentinel.util.AppNameUtil;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -49,6 +56,12 @@ public class SentinelAutoConfiguration {
@Autowired
private SentinelProperties properties;
+ @Autowired
+ private Optional<UrlBlockHandler> urlBlockHandlerOptional;
+
+ @Autowired
+ private Optional<UrlCleaner> urlCleanerOptional;
+
@PostConstruct
private void init() {
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) {
@@ -60,6 +73,11 @@ public class SentinelAutoConfiguration {
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))) {
System.setProperty(TransportConfig.CONSOLE_SERVER, properties.getDashboard());
}
+
+ urlBlockHandlerOptional.ifPresent(WebCallbackManager::setUrlBlockHandler);
+ urlCleanerOptional.ifPresent(WebCallbackManager::setUrlCleaner);
+
+ InitExecutor.doInit();
}
@Bean
