Injecting bean declared in xml file using the @Inject annotation

I can't get @Inject to work properly. I'm trying to inject a bean from xml using the @Inject annotation, but I get the error message "java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required".

I have also been trying in combination with @Qualifier("dataSource"), but wherever I put the @Qualifier it says "The annotation @Qualifier is disallowed for this location".

I have been reading loads of documentation on @Inject and I can't seem to find anything that mentions any special treatment of beans declared in xml.

However, I'm guessing Spring is trying to create the FooDaoImpl bean before scanning the dataSourceBean.

How would I go about using @Inject to inject the dataSource bean declared in the xml file? Is it even possible, using @Inject?

public class FooDaoImpl extends NamedParameterJdbcDaoSupport implements FooDao {

private DataSource dataSource;

DSLContext create = DSL.using(dataSource, SQLDialect.DB2);



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
    xmlns:xsi="" xmlns:context=""

<context:annotation-config /> 
<context:component-scan base-package="com.example.foobar" />

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    <property name="driverClass" value="" />
    <property name="jdbcUrl" value="jdbc:db2://localhost:50000/BLABLA" />
    <property name="user" value="PAPAYA" />
    <property name="password" value="COCONUT" />



This works fine in Spring. I use the @Autowired annotation, not @Inject.

Need Your Help

Defining A Differential Equation Using matlabFunction

matlab function error-handling

I am trying solve the differential equation by first putting it in normal, which, if I did it correctly, should be dx/dt = a8 1/3 x - 1/3 b8, where a8 is the second derivative, and b8 is the third

Clear JPanel or JFrame

java swing graphics drawing

Without using super.paintComponent(g); can i still clear my Jpanel or Jframe Screen? I have some shapes drawn on JPanel and i want to clear all the drawing when user presses the right click without...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.