title: benefit of @Autowired annotation in Java
body: <p>Maybe, because of my wrong English, I couldn't understand the benefit of using @Autowired annotation.</p>
  
  <p>According to the tutorial we can simplify the first(I.) case to second case(II.) by means of @Autowired.</p>
  
  <p><em>My question is, what is the meaning of the @Autowired ? Because it doesnt tell any more, since without using @Autowired the compiler can figure out that "EmpDao emDao" and "EmpManager" are closely related according the declaration.</em></p>
  
  <p>code cited from <a href="http://www.developer.com/article_comments.php/3756831/2/Java-Tip-Simplify-Spring-Apps-with-Autowired.htm" rel="noreferrer">here</a></p>
  
  <p>I.</p>
  
  <pre><code>    &lt;bean id="empDao" class="EmpDao" /&gt;
      &lt;bean id="empManager" class="EmpManager"&gt;
         &lt;property name="empDao" ref="empDao" /&gt;
      &lt;/bean&gt;
  
  public class EmpManager {
  
     private EmpDao empDao;
  
     public EmpDao getEmpDao() {
        return empDao;
     }
  
     public void setEmpDao(EmpDao empDao) {
        this.empDao = empDao;
     }
  
     ...
  }
  </code></pre>
  
  <p>II.</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  
  &lt;bean id="empManager" class="autowiredexample.EmpManager" /&gt;
  &lt;bean id="empDao"     class="autowiredexample.EmpDao" /&gt;
  
  import org.springframework.beans.factory.annotation.Autowired;
  
  public class EmpManager {
  
     @Autowired
     private EmpDao empDao;
  
  }
  </code></pre>