public abstract class AbstractClass {
@Bean
public String getBeanName() {
return "My Bean";
}
}
@Configuration
public class MyClass extends AbstractClass {
@Bean
public String getBeanNameWithoutOverriding() {
return "1 - " + getBeanName();
}
@Bean
public String getSecondBeanNameWithoutOverriding() {
return "2 - " + getBeanName();
}
}
Is this right way to declare bean in abstract class and use it or AbstractClass
need to be annotated as a component also? I think it does not make sense to annotate it with it since it cannot be instantiated. When I do it like in my example, it works as expected but I couldn't find any documentation about it.
In real case, bean returns ThreadPoolExecutor. I want only one instance of it. And OFC abstract class has more logic in it also. What I'm trying point out is, does it work like this?