I want to declare @Bean
in a super abstract class
to prevent declaring it for each subclass.
Consider this class hierarchy:
@Configuration
public class Config {
public static abstract class A {
@Bean
public myBean() {
return new MyBean();
}
}
public static class B extends A {
// Some stuff here
}
public static class C extends A {
// Some other stuff here
}
}
I can't do this in Spring Boot 1.5.9 (Spring Framework 4.3.13).
It throws:
org.springframework.beans.BeanInstantiationException: Failed to instantiate foo.bar.A: Is it an abstract class?
Is there a way to prevent duplicating @Bean
for each subclass?