mongodb - 使用带有 MongoTamplete 的 Spring Boot 2 测试与 MongoDb 的连接
问题描述
我需要定期测试我与 MongoDB 的连接,为此我想使用 MongoTemplate。
我怎样才能做到这一点?
tks。
解决方案
您可以为此使用 Spring Boot Actuator。包括执行器依赖项。在 application.properties 中包括 management.endpoint.health.show-details=ALWAYS。现在您应该能够看到 Mongo Connection 的状态。