本文主要是介绍spring boot之——health监控实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.实现HealthIndicator这个接口
package org.springframework.boot.actuate.health;public interface HealthIndicator {Health health();}
2.AbstractHealthIndicator这个抽象类实现HealthIndicator接口
package org.springframework.boot.actuate.health;import org.springframework.boot.actuate.health.Health.Builder;public abstract class AbstractHealthIndicator implements HealthIndicator {@Overridepublic final Health health() {Health.Builder builder = new Health.Builder();try {doHealthCheck(builder);}catch (Exception ex) {builder.down(ex);}return builder.build();}protected abstract void doHealthCheck(Health.Builder builder) throws Exception;}
3.我们只需要继承这个抽象类,就可以实现业务监控!
代码如下:
import com.alibaba.fastjson.JSON;
import com.yum.ec3.message.bean.BrandExchangeConfigBean;
import com.yum.ec3
这篇关于spring boot之——health监控实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!