<?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">
    <!--该配置文件的作用是用来配置与 Mybatis 框架整合-->

    <!--配置解析properties文件的工具类
    location:要解析的properties文件的位置，src目录会被解析为classpath-->
    <context:property-placeholder location="classpath:db.properties" />

    <!--配置数据源-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>

    <!--配置Spring和Mybatis整合的对象SqlSessionFactory-->
    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!--给实体类起别名-->
        <property name="typeAliasesPackage" value="com.bjsxt.pojo"/>
    </bean>

    <!--配置MapperScannerConfigurer完成接口和映射文件的扫描，生成代理对象-->
    <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <!--给定接口和映射配置文件的包名，会扫描这个包然后生成代理对象-->
        <property name="basePackage" value="com.bjsxt.mapper"/>
    </bean>
</beans>