I want to catch bean instantiation exceptions in my code. What options do I have? One way to do this is to use Java-based container configuration:

@Configuration
public class AppConfig {
  @Bean
  public SomeBean someBean() {
    try {
      return new SomeBean(); // throws SomeException
    } catch(SomeException se) {
      return new SomeBeanStub();
    }
  }
}

Is that possible to define exception handlers for bean instantiation using Spring using XML-based or annotation-based configuration?

Edit
Report