I tried to create 2 bins:
@Component class A{...} @Component class B extends A{...} but when autowire- ping error
No qualifying bean of type is found:
What should I do if I need to inherit one bin from another?
I tried to create 2 bins:
@Component class A{...} @Component class B extends A{...} but when autowire- ping error
No qualifying bean of type is found:
What should I do if I need to inherit one bin from another?
And how should Spring understand in which case which bean to use? Or, give the bin a name and inject the concrete with @Qualifier :
@Component("a") class A{...} @Component("b") class B extends A{...} @Autowired @Qualifier("b") A b; @Autowired @Qualifier("a") A a; A a1 = appContext.getBean("a"); A b1 = appContext.getBean("b"); or refuse @Autowired and configure dependencies manually via setters.
getBean() (although you can do without 99% of this), give the bin a name via @Component("a") and @Component("b") . - Nofate ♦Source: https://ru.stackoverflow.com/questions/530376/
All Articles