则春季启动启动失败

则春季启动启动失败

本文介绍了如果无法访问mongo主机,则春季启动启动失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Spring boot mongo db应用程序,如果mongo主机还活着,当我开始运行此应用程序时,能够看到我的应用程序已启动并成功运行,如果我的Mongo主机在我启动我的应用程序时关闭,则我的应用程序无法启动.甚至没有想到,如果mongo主机关闭了,我的应用程序应该已经启动并正在运行.

I have Spring boot mongo db app, when i start running this application if mongo host is alive, am able to see the my app is up and running successfully,if my mongo host is down when i start my application my app failed to start.is there any way even thought if mongo host is down my application should be up and running.

有人可以帮我吗?

在我的应用程序中使用spring boot mongo属性

am using spring boot mongo properties in my application

spring.data.mongodb.repositories.enabled=true

spring.data.mongodb.port=27017

spring.data.mongodb.database=db

spring.data.mongodb.uri=mongodb://mongo-node-1.ballu/db

spring boot kafka也有同样的问题.

have same problem with spring boot kafka also.

推荐答案

对不起,上一条评论.无论如何,这是为了排除自动配置bean

Sorry for the previous comment. It was for excluding auto config beans, anyway

是的,spring.datasource.continue-on-error=true #Whether to stop if an error occurs while initializing the database.

根据spring 文档

从春季Kafka开始尝试此操作(我不确定这是否满足您的要求)

and as of spring kafka try this(i'm not sure if this meets your requirement)

spring.kafka.admin.fail-fast=true # Whether to fail fast if the broker is not available on startup.

这篇关于如果无法访问mongo主机,则春季启动启动失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:48