SpringBoot拦截所有HealthIndicator健康检查方法
为避免健康检查失败导致Kubernetes服务重启,开发者需要拦截所有HealthIndicator调用并记录失败组件。由于HealthIndicator的实现方式,基于执行的切点无法拦截所有调用。
解决方法是使用基于@annotation的切点:
@Around("@annotation(org.springframework.boot.actuate.health.HealthIndicator)") public Object healthIndicatorAdvice(ProceedingJoinPoint pjp) throws Throwable { // 在此处记录失败的HealthIndicator实现 Object result = pjp.proceed(); // 在此处进一步处理result return result; }
此方法可拦截所有标注了@HealthIndicator注解的HealthIndicator实现的health()方法。
以上就是SpringBoot如何拦截所有HealthIndicator的健康检查?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号