title: Ways in which Spring do Dependency Injection
body: <p>I have some experience in Spring Framework. Spring usually do the DI using the <code>constructor injection</code> or <code>setter injection</code>. This concept I am comfortable. Now, in addition to this, I have seen the Spring do DI like this:</p>
  
  <pre><code>@Autowired
  DataSource myData;
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <pre><code>@Resouce(name="someName")
  SomeDependency dependency;
  </code></pre>
  
  <p>What mechanism do Spring utilise when it uses annotations to do the DI?  Does Spring use <code>constructor</code> or <code>setter</code> injection in these cases or is annotation driven approach altogether a different way of injecting the dependencies?</p>
  
  <p>Any explanation in simple worlds would be of great help.</p>