title: @Autowired by constructor looks for beans by type. How to inject a bean by name to a constructor using autowired annotation
body: <p><code>@Autowired</code> by constructor looks for beans by type. How to inject a bean by name to a constructor using autowired  annotation?
  I have 2 beans of same type but I need to inject it to constructor of another same class based on the bean name. How do I do it?</p>
  
  <p>XML:</p>
  
  <pre><code> &lt;bean id="A" class="com.Check"/&gt;
   &lt;bean id="B" class="com.Check"/&gt;
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>Class C {
  
     private Check check;
  
     @Autowired
     public C(Check check){
         this.check = check
     }
  
    }
  </code></pre>
  
  <p>When I do this I get an exception telling me that I have 2 beans of same type check but it requires there to be just one bean of that type. How can I inject the bean with <code>id="B"</code> into this class <code>C</code> through constructor injection?</p>
  
  <p>In my <code>applicationContext.xml</code> I have mentioned <code>autowire="byType"</code>. I need to autowire <code>byName</code> only in this particular class rest all it needs to be autowired by Type only</p>