<?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">
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <!-- 1.配置数据源 -->
    <bean id="dataSource"
          class="com.alibaba.druid.pool.DruidDataSource">
        <!-- 1.1.数据库驱动 -->
        <property name="driverClassName"
                  value="${jdbc.driverClassName}"></property>
        <!-- 1.2.连接数据库的url -->
        <property name="url"
                  value="${jdbc.url}"></property>
        <!-- 1.3.连接数据库的用户名 -->
        <property name="username" value="${jdbc.username}"></property>
        <!-- 1.4.连接数据库的密码 -->
        <property name="password" value="${jdbc.password}"></property>
        <property name="initialSize" value="${jdbc.initialSize}"></property>
        <property name="maxWait" value="${jdbc.maxWait}"></property>
        <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"></property>
        <property name="filters" value="${jdbc.filters}"></property>

    </bean>

    <!-- 2配置JDBC模板 -->
    <bean id="jdbcTemplate"
          class="org.springframework.jdbc.core.JdbcTemplate">
        <!-- 默认必须使用数据源 -->
        <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!-- 定义id为dataDao的Bean -->
    <bean id="dataDao" class="com.xiaomai.jdbc.dao.impl.DataDaoImpl">
        <!-- 将jdbcTemplate注入到dataDao实例中 -->
        <property name="jdbcTemplate" ref="jdbcTemplate"></property>
    </bean>


</beans>