在我为应用程序添加了以下健康指标和预热事件后,我收到错误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();
}
}
}