定义一个DAO,需要extends JdbcDaoSupport
<bean id="customerDAO"
class="CustomerDAOJdbcImp" singleton="true">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
然后,在类里面就可以获得JdbcTemplate template = getJdbcTemplate();

解决方案 »

  1.   

    难道不是JdbcTemplate template = getJdbcTemplate(dataSource);吗??
    你这样写完应该再setdataSource吧?
      

  2.   

    自己顶.
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location"><value>jdbc.properties</value></property>
    </bean>
    ====================================================================================
    propertyConfigurer能否自动的为dataSource中的${jdbc.xxx}赋值,我们只要
    ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
    DataSource ctx=(DataSource)ctx.getBean("dataSource");就可以取得到我们想要得dataSource呢?
      

  3.   

    用 leowu(leo)的办法就行,要把dataSource配进去