How to configure Spring to continue load its beans, if one of its defined beans in its init method throwed exception. lazy-init=”true” option doesn’t help – it is just ignored. In this bean init() method i try to open connection with server, which may fail to load the application spring context. Spring 3.0.6
Share
The Idea of Exceptions is to fix the cause of them, not to ignore them.
Have that said: I have never seen anything for that: you have to do it by our own. Put a try catch around the init method that consume the exception and log it.
If you have real AspectJ, then you can use it for that task too. But Spring-AOP will not work.
In this case. what about a factory that provides the bean which causes the trouble to the context. The factory should check the connection first (or wait for the exception) (what exactly you do is an implementation detail) and return the bean if every thing is correct. If the connection is failing, then the factory return a Dummy implementation instead..