【问题标题】:Test connection with MongoDb using Spring Boot 2 with MongoTamplete使用带有 MongoTamplete 的 Spring Boot 2 测试与 MongoDb 的连接
【发布时间】:2018-11-13 14:00:20
【问题描述】:

我需要定期测试我与 MongoDB 的连接,为此我想使用 MongoTemplate。

我该怎么做?

tks.

【问题讨论】:

  • 不要... Spring Boot 已经为此进行了健康检查,为什么不简单地使用它(只需在您的项目中包含 Sprign Boot Actuator 并自动获取它)。

标签: mongodb spring-boot mongotemplate


【解决方案1】:

您可以为此使用 Spring Boot Actuator。包括执行器依赖项。在 application.properties 中包括 management.endpoint.health.show-details=ALWAYS。现在您应该可以看到 Mongo Connection 的状态了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    • 2021-06-06
    • 1970-01-01
    • 2020-07-23
    • 2019-12-10
    • 2019-10-26
    • 2017-11-12
    相关资源
    最近更新 更多