0

Is there any other way to check the health of MongoDB rather than using this.

@Override
public String mongoDbHealthCheck() {
    try {
        mongoTemplate.executeCommand("{ serverStatus: 1 }");
        return "Yes";
    }
    catch(Exception e) {
        log.error(e.getMessage());
        return "No";
    }
}

1 Answers1

0

You can define it like this;

management.health.mongo.enabled=true

Spring Boot Mongo health definiton