title: NoUniqueBeanDefinitionException: No qualifying bean of type 'beans.Engin' available: expected single matching bean but found 2
body: <p>I created Car class having field of Engine class type annotated with @Autowired. When I use @Qualifer getting following error: </p>
  
  <p>org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'beans.Engine' available: expected single matching bean but found 2: def,abc</p>
  
  <p>I am using DTD instead of context schema in spring.xml. Below is the xml file:</p>
  
  <pre><code>&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN""http://www.springframework.org/dtd/spring-beans-2.0.dtd"&gt;
  
  &lt;beans&gt;
  &lt;bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/&gt;
  &lt;bean id="def" class="beans.Engine"&gt;
      &lt;property name="modelYear" value="2015"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="abc" class="beans.Engine"&gt;
      &lt;property name="modelYear" value="2015"/&gt;
  &lt;/bean&gt;
  &lt;bean id="c" class="beans.Car"/&gt;    
  &lt;/beans&gt;
  </code></pre>
  
  <p>Car.java</p>
  
  <p>public class Car {</p>
  
  <pre><code>@Autowired
  @Qualifier(value="def")
  private Engine engine;
  
  public void printCarData(){
          System.out.println("Engine Model Year  :  "+engine.getModelYear());
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Engine.java</p>
  
  <p>public class Engine {</p>
  
  <pre><code>private String modelYear;
  
  public void setModelYear(String modelYear) {
      this.modelYear=modelYear;
  }
  
  public String getModelYear() {
      return modelYear;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Client.java</p>
  
  <p>public class Client {</p>
  
  <pre><code>public static void main(String [] a){       
  
      ApplicationContext ap = new ClassPathXmlApplicationContext("resources/spring.xml");
  
      Car c = (Car)ap.getBean("c");
      c.printCarData();
  }
  </code></pre>
  
  <p>}</p>