Does Spring DI have a fall back mechanism ?
What I mean by above is, if a bean A
instantiation is not possible for some reason, then can a bean B
be instantiated and auto-wired automatically.
The use case is - in testing, if db bean can't be instantiated due to network connectivity. I want a mock bean to be injected.
You can use @Autowired(required = false) for class A and B and check in a @PostConstruct method if either A or B are initialized. But I don't know any mechanism to only use @Autowired if an other @Autowired failed.