Spring-dao-JDBC模板之Spring注册数据源

感觉写的时候 很奇妙啊

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=”http://www.springframework.org/schema/context” 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”>

<!– 注册数据源: Spring内置的数据源 –>
<!– <bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”com.mysql.jdbc.driver”/>
<property name=”url” value=”jdbc:mysql://127.0.0.1:3306/test”/>
<property name=”username” value=”root”/>
<property name=”password” value=”root”/>
</bean> –>

<!– 注册数据源: C3P0数据源 –>
<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.user}”/>
<property name=”password” value=”${jdbc.password}”/>
</bean>

<!– 注册数据源: DBCP数据源 –>
<!– <bean id=”dataSource” class=”org.apache.commons.dbcp.BasicDataSource”>
<property name=”driverClassName” value=”com.mysql.jdbc.driver”/>
<property name=”url” value=”jdbc:mysql://127.0.0.1:3306/test”/>
<property name=”username” value=”root”/>
<property name=”password” value=”root”/>
</bean> –>

<!– 注册jdbc属性文件 –>
<context:property-placeholder location=”classpath:jdbc.properties”/>
<!– <bean id=”jdbcTemplate” class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”>
<property name=”location” value=”classpath:jdbc.priperties”/>
</bean>
–>

<!– 注册Jdbc模板对象与Dao –>
<bean id=”studentDao” class=”com.gotkx.dao.StudentDaoImpl”>
<property name=”dataSource” ref=”dataSource”/>
</bean>

<!– 注册Jdbc模板对象 –>
<!– <bean id=”jdbcTemplate” class=”org.springframework.jdbc.core.JdbcTemplate”>
<property name=”dataSource” ref=”dataSource”/>
</bean> –>

<!– 注册Dao –>
<!– <bean id=”studentDao” class=”com.gotkx.dao.StudentDaoImpl”>
<property name=”jdbcTemplate” ref=”jdbcTemplate”/>
</bean> –>

<!– 注册Service –>
<bean id=”studentService” class=”com.gotkx.service.StudentServiceImpl”>
<property name=”dao” ref=”studentDao”/>
</bean>

</beans>