title: Injecting bean declared in xml file using the @Inject annotation
body: <p>I can't get <code>@Inject</code> to work properly. I'm trying to inject a bean from xml using the <code>@Inject</code> annotation, but I get the error message
  <code>"java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required"</code>.</p>
  
  <p>I have also been trying in combination with <code>@Qualifier("dataSource")</code>, but wherever I put the <code>@Qualifier</code> it says <code>"The annotation @Qualifier is disallowed for this location"</code>.</p>
  
  <p>I have been reading loads of documentation on <code>@Inject</code> and I can't seem to find anything that mentions any special treatment of beans declared in xml.</p>
  
  <p>However, I'm guessing Spring is trying to create the FooDaoImpl bean before scanning the dataSourceBean. </p>
  
  <p><strong>How would I go about using <code>@Inject</code> to inject the dataSource bean declared in the xml file?
  Is it even possible, using <code>@Inject</code>?</strong></p>
  
  <p>FooDaoImpl.java</p>
  
  <pre><code>@Repository
  public class FooDaoImpl extends NamedParameterJdbcDaoSupport implements FooDao {
  
  @Inject
  private DataSource dataSource;
  
  DSLContext create = DSL.using(dataSource, SQLDialect.DB2);
  
  }
  </code></pre>
  
  <p>Spring-Module.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
  &lt;context:annotation-config /&gt; 
  &lt;context:component-scan base-package="com.example.foobar" /&gt;
  
  &lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
      destroy-method="close"&gt; 
      &lt;property name="driverClass" value="com.ibm.db2.jcc.DB2Driver" /&gt;
      &lt;property name="jdbcUrl" value="jdbc:db2://localhost:50000/BLABLA" /&gt;
      &lt;property name="user" value="PAPAYA" /&gt;
      &lt;property name="password" value="COCONUT" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>Cheers!</p>