1.在原来xmlns下面添加一行
xmlns:context="http://www.springframework.org/schema/context"
2.在原来xsi:schemaLocation中添加不同的内容(也可以直接复制粘贴全部替代全部xsi的内容)
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
加载配置文件
<!--加载jdbc.properties-->
<context:property-placeholder location="classpath:jdbc.properties"/>
加载数据源对象以及jdbc模板对象
<!--数据源对象-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}"/>
<property name="password" value="${jdbc.pwd}"/>
</bean>
<!--jdbc模板对象-->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<!--这里的ref = dataSource 是指bean上面的id(数据源的id)-->
<property name="dataSource" ref="dataSource"/>
</bean>