定义一个DAO,需要extends JdbcDaoSupport
<bean id="customerDAO"
class="CustomerDAOJdbcImp" singleton="true">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
然后,在类里面就可以获得JdbcTemplate template = getJdbcTemplate();
<bean id="customerDAO"
class="CustomerDAOJdbcImp" singleton="true">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
然后,在类里面就可以获得JdbcTemplate template = getJdbcTemplate();
你这样写完应该再setdataSource吧?
<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呢?