Hi All,

I know that using xml configuration, we can define several bean elements, with different bean ids, but each of those beans are actually instance of same class. But how does this work in autowiring world. I will try to explain my question with an ex.

Say, I have my classes defined as below

Code:
public class Employee{

@Autowired
@Qualifer("hr")
 private Work hr;

@Autowired
@Qualifier("finance")
 private Work finance;

@Autowired
@Qualifer("callcenter")
 private Work callcenter;

 public void doWork(Work work){
         work.doWork();
 }

}

Code:
public interface Work{
   public void doWork();
}

@Component("component")
public class WorkType implements Work{
    private String workName;
     ..........
     ..........
}
Now in context file
Code:
<bean name="hr" class = "WorkType">
   <property name="workName" value ="recruit"/>
</bean>

<bean name="finance" class = "WorkType">
   <property name="workName" value ="funds"/>
</bean>

<bean name="callcenter" class = "WorkType">
   <property name="workName" value ="business"/>
</bean>
Now as you see, I used @Component annotation as @Component("component") for WorkType class, but I autowired three instances with different Qualifiers in Employee class.

My question here is, I'm mixing annotations with xml configuration here and as far as I know, xml overwrites annotations. But since I declared a class with @Component("component") and then autowired with different names, would it cause the application to blow up under any situation. Does the autowiring conflict with the value defined under @Component.

Please advise.