无法通过端口9001连接到MBean服务器-ApplicationReadyEvent之后的运行状况检查

问题描述

在我为应用程序添加了以下健康指标和预热事件后,我收到错误Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.2.RELEASE:start (pre-integration-test) Could not figure out if the application has started: Failed to connect to MBean server at port 9001: Could not invoke shutdown operation: Connection refused to host: 127.0.0.1; nested exception is: [ERROR] java.net.ConnectException: Connection refused (Connection refused)。不知道为什么我得到这个错误。请指教

在ApplicationReadyEvent之后如何执行执行器健康检查?还是不需要ApplicationReadyEvent?

@Component
public class Warmup implements Healthindicator,ApplicationListener<ApplicationReadyEvent> {

    private boolean warmUpOver;

    @Autowired
    public Warmup(){
       
    }

    @Override
    public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
        warmUpMethod();
    }

    public void warmUpMethod(){
        //Once the method is over 
        warmUpOver = true;
    }

    @Override
    public Health health() {
        if(warmUpOver){
            final Health.Builder builder = Health.up();
            return builder.build();
        } else {
            final Health.Builder builder = Health.unkNown();
            return builder.build();
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)