<?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:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    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/aop 
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">
    <context:property-placeholder location="classpath:spring/config.properties" />
    <import resource="classpath:spring/spring-echat-redis.xml" />
    <bean class="cn.com.flaginfo.web.cache.RedisCacheConfig" />
    <aop:aspectj-autoproxy proxy-target-class="true" />
    <bean id="dataSource" 
        class="com.alibaba.druid.pool.DruidDataSource" 
        init-method="init" 
        destroy-method="close"
        p:url="${db.url}"
        p:username="${db.user}"
        p:password="${db.password}"
    />
    <!-- Transaction Manager  -->
    <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource" />
    <tx:annotation-driven transaction-manager="transactionManager" /> 
    <!-- MyBatis SqlSessionFactory -->
    <bean id="sqlSessionFactory" class="me.chyxion.tigon.dao.mybatis.SqlSessionFactoryBeanExt"
        p:dataSource-ref="dataSource"
        p:configLocation="classpath:mybatis/mybatis-config.xml"
        p:typeAliasesPackage="${project.groupId}.**.models" 
        p:mapperLocations="classpath*:mybatis/mappers/**/*-mapper.xml">
        <property name="plugins">
            <list>
                <bean class="me.chyxion.tigon.dao.mybatis.pagination.PaginationIntercepter"
                    p:dataSource-ref="dataSource" />
            </list>
        </property>
    </bean>
    <!-- MyBatis Mapper Auto Scan -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="${project.groupId}.**.mappers"
        p:sqlSessionFactoryBeanName="sqlSessionFactory"
    />
</beans>
