开发者社区 > 云原生 > 正文

@SentinelResource注解没有加 blockHandler 使用blockHandle

@SentinelResource注解没有加 blockHandler 使用blockHandlerClass 替代。

@SentinelResource( value = "client/log/save", blockHandlerClass = DiscoveryClientControllerBackHandler.class, fallbackClass = DiscoveryClientControllerFallBackHandler.class )

发现后台日志打印 com.alibaba.csp.sentinel.slots.block.flow.FlowException: null

前端显示 This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Nov 16 22:43:32 CST 2019 There was an unexpected error (type=Internal Server Error, status=500). No message available

不是DiscoveryClientControllerBackHandler设定好的内容。

debug 发现代码

提问186.png

提问187.png

继续跳转到 handleFallback 处理类上

提问188.png

也是同样的问题。

提问189.png

同样直接返回null

以下是我的版本信息 spring cloud alibaba 版本 2.1.0.RELEASE spring cloud 版本 Greenwich.RELEASE spring boot 版本 2.1.7.RELEASE

sentinel 版本 是1.6.3

原提问者GitHub用户Hpxianliru

展开
收起
码字王 2023-05-19 16:56:30 127 0
1 条回答
写回答
取消 提交回答
  • 仔细看下文档,blockHandlerClass 要搭配 blockHandler 用的,用于指定 blockHandler 函数所在的类:https://github.com/alibaba/Sentinel/wiki/注解支持#sentinelresource-注解

    原回答者GitHub用户sczyh30

    2023-05-19 22:43:26
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载