关于 spring cloud alibaba 2.2.0 引入 sentinel 找不到 WebCallBackManager
spring cloud alibaba 2.2.0
- 需要引入sentinel-spring-webmvc-dapter , 基于 Spring 的 Interceptor 拦截资源,而不再是 CommonFilter。
- 不兼容UrlBlockHandler
- 使用BlockExceptionHandler
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-spring-webmvc-adapter</artifactId>
</dependency>
-
`
@Component
public class SeckillSentinelConfig implements BlockExceptionHandler {@Override
public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
R r = R.error(BizCodeEnum.TO_MANY_REQUEST.getCode(), BizCodeEnum.TO_MANY_REQUEST.getMsg());
response.setContentType(“application/json;charset=utf-8”);
response.getWriter().write(JSON.toJSONString®);
}
}`