开发者

Continue to load webapp even if one spring bean initialization fails

So if spring initialization fails in a webapp then the webapp itself does not come up. To prevent this, I can probably not re-throw any exception from my code for that specific bean initialization and the webapp will continue to load,开发者_Python百科 right?

Is there any other way to tell to spring not to fail the webapp itself on particular bean initialization failure?


Continue to load webapp even if one spring bean initialization fails

AFAIK, you can't do this.

I do multiple DNS lookups on start up. I do not want the webapp to fail if one of them fails.

In that case, you need to modify your bean(s) to handle the case where the DNS lookup fails, leaving the bean instance in a state where it is essentially inactive but harmless, or where it can retry the DNS lookup later on.

In short, you have to cope with this yourself.


Have attribute lazy-init="true" in that bean and every dependant bean. Link for more details.


why would you do this? If your spring context is not correct, something is seriously wrong and there will be issues. The correct way to deal with this is to fix the application context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜