刚学完Spring,但是在写小练习的时候发现了一个问题。比如说,我使用XML配置IOC,来模拟如下两句代码。
JdbcTemplate jt = new JdbcTemplate()
QueryRunner qr = new QueryRunner()
XML的配置如下

然后读取该xml配置文件。写如下代码
ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
然后就会报错,说无法注入myjt这个Bean到容器中,必须为其配置DataSource属性。图片如下:

而QueryRunner对象的创建并不需要配置DataSource属性。
请问,怎么回事?
JdbcTemplate jt = new JdbcTemplate()
QueryRunner qr = new QueryRunner()
XML的配置如下

然后读取该xml配置文件。写如下代码
ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");
然后就会报错,说无法注入myjt这个Bean到容器中,必须为其配置DataSource属性。图片如下:

而QueryRunner对象的创建并不需要配置DataSource属性。
请问,怎么回事?