spring-mysql-datasource.xml 1.37 KB
<?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:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    <!-- DAO接口所在包名,Spring会自动查找其下的类 -->
    <bean id="mysqlScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.monitor.mysql.mapper"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
    </bean>

    <bean id="zabbixScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.monitor.zabbix.mapper"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
    </bean>

    <aop:config>
        <aop:pointcut id="monitorDaoPoint"
                      expression="execution(* com.monitor.mysql.mapper.*.*(..)) or execution(* com.monitor.zabbix.mapper.*.*(..))"/>
        <aop:advisor pointcut-ref="monitorDaoPoint" advice-ref="dataSourceMethodInterceptor"/>
    </aop:config>

</beans>