I get the error 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)
after I added below health metric and warm up event for the application. Not sure why I get this error. Please advise
How to perform actuator health check after ApplicationReadyEvent? or ApplicationReadyEvent is not required?
@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();
}
}
}