<?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" xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
    <tx:annotation-driven transaction-manager="dataSourceTransactionManager" />

    <context:component-scan base-package="com.db.service.*">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
    </context:component-scan>

    <bean id="mysqlDataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://192.168.0.11:3306/elab_db?useSSL=false"/>
        <property name="username" value="root"/>
        <property name="password" value="Elab@123"/>
        <property name="initialSize" value="50"/>
        <property name="maxActive" value="100"/>
        <property name="minIdle" value="1"/>
        <property name="maxWait" value="60000"/>
        <property name="validationQuery" value="select 1 from dual"/>
        <property name="testOnBorrow" value="false"/>
        <property name="testOnReturn" value="false"/>
        <property name="testWhileIdle" value="true"/>
        <property name="timeBetweenEvictionRunsMillis" value="60000"/>
        <property name="minEvictableIdleTimeMillis" value="25200000"/>
        <property name="removeAbandoned" value="true"/>
        <property name="removeAbandonedTimeout" value="1800"/>
        <property name="logAbandoned" value="true"/>
        <property name="filters" value="mergeStat"/>
    </bean>


    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="mysqlDataSource"/>
    </bean>

    <bean id="basicBaseDao" class="com.elab.core.dao.BasicBaseDao">
        <property name="jdbcTemplate" ref="jdbcTemplate"/>
    </bean>

    <!-- 构建一个配置工厂 -->
    <bean id="configurableFactory" class="com.elab.core.sql.ConfigurableFactory">
        <property name="sqlConfigurableLocations" value="sql"/>
    </bean>

    <!-- 扫描包 -->
    <bean id="daoScannerConfigurer" class="com.elab.core.spring.DaoScannerConfigurer">
        <property name="basePackage" value="com.db.service.dao"/>
        <property name="basicBaseDaoName" value="basicBaseDao"/>
        <property name="configurableFactory" ref="configurableFactory"/>
    </bean>

    <bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="mysqlDataSource"/>
    </bean>

</beans>