NoSuchBeanDefinitionException: No unique bean of type is define. While two beans of same type <p>This is first time I am using @autowiring, I have a example.</p> <p>I want to use <strong>Autowiring by TYPE</strong> , SO that at Run time container injects appropriate Object and calls appropriate bean/method. </p> <p><strong>1.INTERFACE</strong></p> <pre><code> public interface Calculator { public int add(int a,int b); } </code></pre> <p><strong>2.First Class</strong></p> <pre><code>public class CalculatorImpl implements Calculator { public int add(int a, int b) { // TODO Auto-generated method stub int result=a+b; return result; } </code></pre> <p>}</p> <p><strong>3.Second Class</strong></p> <pre><code>public class CalculatorImpl2 implements Calculator{ public int add(int a, int b) { // TODO Auto-generated method stub int result=a-b; return result; } </code></pre> <p>}</p> <p><strong>4.REST CLASS</strong></p> <pre><code>@Component @Path("/calc") public class CalculationService { @Autowired Calculator calculator; @GET @Path("/add/{a}/{b}/") @Qualifier("calculatorImpl") @Produces("text/plain") public Response serveAdd(@PathParam("a") int a, @PathParam("b") int b) { int result= calculator.add(a, b); return Response.status(200).entity(String.valueOf(result)).build(); } @GET @Path("/sub/{a}/{b}") @Qualifier("calculatorImpl2") public Response serveSub(@PathParam("a") int a, @PathParam("b") int b) { int result= calculator.add(a, b); return Response.status(200).entity(String.valueOf(result)).build(); } } </code></pre> <p><strong>5.APPLICATION-CONTEXT.xml</strong></p> <pre><code>&lt;context:component-scan base-package="com.veke.rest" /&gt; &lt;bean id="calculatorImpl" class="com.veke.calcImpl.CalculatorImpl" autowire="byType"/&gt; &lt;bean id="calculatorImpl2" class="com.veke.calcImpl.CalculatorImpl2" autowire="byType"/&gt; &lt;/beans&gt; </code></pre> <p><strong>ERROR:</strong></p> <blockquote> <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'calculationService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.veke.calc.Calculator com.veke.rest.CalculationService.calculator; nested exception is org.springframework.beans.factory.<strong>NoSuchBeanDefinitionException: No unique bean of type [com.veke.calc.Calculator] is defined: expected single matching bean but found 2: [calculatorImpl, calculatorImpl2]</strong></p> </blockquote> <p>Have I done correct things? Or I am wrong.</p> <p>I have done this with my understanding of @autowiring.</p> <p>Many Thanks :)</p> <p>Edit: <code>@Qualifier</code> is solution for this problem.(As i Have two beans with same type in context). Its used to solve ambiguity problem. <code>@Autowired</code> is <strong>by Type</strong>. </p>