【问题标题】:How to skip the failed beans in springboot to avoid reportFailure:771 >> Application startup failedspringboot中如何跳过失败的bean来避免reportFailure:771>>应用程序启动失败
【发布时间】:2018-09-01 06:19:29
【问题描述】:

有什么办法可以跳过失败bean,避免应用启动失败。让我解释一下场景。

我在应用程序启动时创建 hazlecast bean。有时 hazlecast 服务器可能不活动。在那个时候,当我启动 springboot 应用程序 hazecast 实例失败时,应用程序启动也失败了。

创建名为“hazelcastInstance”的 bean 时出错 [restartedMain] 错误 org.springframework.boot.SpringApplication ,reportFailure:771 >> 应用程序启动失败

但我的应用程序不仅有hazecast bean,它还有很多用于各种服务的bean。是否有可能跳过失败的bean以启动应用程序??

【问题讨论】:

    标签: java spring spring-mvc spring-boot spring-bean


    【解决方案1】:

    您可以用@Lazy 标记它们的bean,这样spring 就不会在应用程序启动时构造它们。它会在你使用它们运行时构造它们。

    请参阅此文档

    https://memorynotfound.com/lazy-initialize-autowired-dependencies-with-lazy-annotation/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-24
      • 2012-12-15
      • 2013-11-13
      • 2017-10-07
      • 2019-04-04
      • 1970-01-01
      相关资源
      最近更新 更多