sentinel1.8.1Sentinel 链路流控模式失效

1.7.0 版本开始(对应Spring Cloud Alibaba的2.1.1.RELEASE) 需要新增依赖

<dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-web-servlet</artifactId>
        </dependency>

配置spring.cloud.sentinel.web-context-unify=false

新增配置 CommonFilter就在上面的依赖里

@Configuration
public class FilterContextConfig {
    @Bean
    public FilterRegistrationBean sentinelFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new CommonFilter());
        registration.addUrlPatterns("/*");
        // 入口资源关闭聚合
        registration.addInitParameter(CommonFilter.WEB_CONTEXT_UNIFY, "false");
        registration.setName("sentinelFilter");
        registration.setOrder(1);
        return registration;
    }
}

参考:https://github.com/alibaba/sentinel/issues/1213
posted @ 2021-02-19 10:33  醉逍遥_001  阅读(1243)  评论(0编辑  收藏  举报