KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Example interface IA { public void someFunction(); } @Resource(name="b") class B implements IA { public void someFunction() { //busy code block } public void someBfunc() { //doing b things } } @Resource(name="c") class C implements IA { public void someFunction() { //busy code block } public void someCfunc() { //doing C things } } class MyRunner { @Autowire @Qualifier("b") IA worker; worker.someFunction(); } Can someone explain this to me. How does spring know which polymorphic type to use. Do I need @Qualifier or @Resource ? Why do we autowire the interface and not the implemented class?
Tags (comma-separated)
Save Edits
Cancel