title: Understanding Spring @Autowired usage
body: <p>I am reading the spring 3.0.x reference documentation to understand Spring Autowired annotation:</p>
  
  <p><a href="http://docs.spring.io/spring/docs/3.0.x/reference/beans.html#beans-autowired-annotation" rel="noreferrer">3.9.2 @Autowired and @Inject</a></p>
  
  <p>I am not able to understand the below examples. Do we need to do something in the XML for it to work? </p>
  
  <p>EXAMPLE 1</p>
  
  <pre><code>public class SimpleMovieLister {
  
      private MovieFinder movieFinder;
  
      @Autowired
      public void setMovieFinder(MovieFinder movieFinder) {
          this.movieFinder = movieFinder;
      }
  
      // ...
  }
  </code></pre>
  
  <p>EXAMPLE 2 </p>
  
  <pre><code>public class MovieRecommender {
  
      private MovieCatalog movieCatalog;
  
      private CustomerPreferenceDao customerPreferenceDao;
  
      @Autowired
      public void prepare(MovieCatalog movieCatalog,
                      CustomerPreferenceDao customerPreferenceDao) {
          this.movieCatalog = movieCatalog;
          this.customerPreferenceDao = customerPreferenceDao;
      }
  
      // ...
  }
  </code></pre>
  
  <p>How can the two classes be autowired implementing the same interface and using the same class? </p>
  
  <p>Example: </p>
  
  <pre><code>class Red implements Color
  class Blue implements Color
  
  class myMainClass{
      @Autowired 
      private Color color;
  
      draw(){
          color.design(); 
      } 
  }
  </code></pre>
  
  <p>Which design method will be called? How do I make sure the design method of Red class will be called and not Blue?</p>