无法连接到端口9001处的mbean服务器-applicationreadyevent之后的运行状况检查

epfja78i  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(807)

我得到了错误 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?

@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();
        }
    }
}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题