美文网首页
Spring+mybatis多数据源配置

Spring+mybatis多数据源配置

作者: 传葱 | 来源:发表于2019-02-22 18:33 被阅读0次
     <bean id="dataSource" class="com.wormpex.fd.wddl.group.support.GroupDataSource">
            <constructor-arg name="dataSourceKey" value="inf_pay_center_man"/>  <!-- 这里需要填写数据库名称,不需要用配置文件了,dev/beta/prod数据库名称必须保持一致 -->
        </bean>
    
        <!--第二套数据源-->
        <bean id="dataSourceBank" class="com.wormpex.fd.wddl.group.support.GroupDataSource">
            <constructor-arg name="dataSourceKey" value="pay_center_bank_info"/>  <!-- 这里需要填写数据库名称,不需要用配置文件了,dev/beta/prod数据库名称必须保持一致 -->
        </bean>
    
        <!--<bean id="transactionManager" class="com.wormpex.inf.wmq.tx.WTransactionManager">-->
            <!--<constructor-arg name="dataSource" ref="dataSource"/>-->
        <!--</bean>-->
    
        <!--<tx:annotation-driven transaction-manager="transactionManager"/>-->
    
        <!--<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">-->
            <!--<constructor-arg name="dataSource" ref="dataSource"/>-->
        <!--</bean>-->
        <!--<tx:annotation-driven transaction-manager="transactionManager"/>-->
    
        <!-- 创建SqlSessionFactory -->
        <bean id="sqlSessionFactory" name="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>
            <property name="mapperLocations" value="classpath*:mappers/*.xml"/>
            <!--<property name="typeAliasesPackage" value="com.wormpex.cvs.userbalance.service"/>-->
        </bean>
    
        <bean id="sqlSessionBankFactory" name="sqlSessionBankFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSourceBank"/>
            <property name="configLocation" value="classpath:bankMybatis/mybatis-config.xml"/>
            <property name="mapperLocations" value="classpath*:bankMappers/*.xml"/>
            <!--<property name="typeAliasesPackage" value="com.wormpex.cvs.userbalance.service"/>-->
        </bean>
    
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.wormpex.paycenter.man.service.dao"/>
            <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
        </bean>
    
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.wormpex.paycenter.man.service.bankDao"/>
            <property name="sqlSessionFactoryBeanName" value="sqlSessionBankFactory"/>
        </bean>
    

    相关文章

      网友评论

          本文标题:Spring+mybatis多数据源配置

          本文链接:https://www.haomeiwen.com/subject/qifyyqtx.html