惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Latest news
Latest news
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
L
Lohrmann on Cybersecurity
aimingoo的专栏
aimingoo的专栏
B
Blog
T
Threat Research - Cisco Blogs
罗磊的独立博客
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
P
Palo Alto Networks Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
T
Tor Project blog
阮一峰的网络日志
阮一峰的网络日志
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
IT之家
IT之家
B
Blog RSS Feed
Scott Helme
Scott Helme
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Schneier on Security
Hacker News: Ask HN
Hacker News: Ask HN
N
Netflix TechBlog - Medium
L
LangChain Blog
博客园 - 叶小钗
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
W
WeLiveSecurity

博客园 - wingfay

【转载】解决 安装或卸载软件时报错Error 1001 的问题 Win7下做一个Kubernetes的NetCore项目Demo win7 升级Power Shell到4.0 .net Cache 需要注意的地方 SQL 字段修改 Powser Design 16.5 导入Mysql数据库的bug ActiveMq Windows 配置优化 Eclipse使用Maven创建Web时错误:Could not resolve archetype 更新VS2017会出现“请更新 Visual Studio 安装程序 再继续” 提示 ipv6过审函数 转.iPhone开发网站、论坛、博客 NSLog的使用 Could not load type System.Security.Authentication..... [原创]Prism Command 和 IsEnabled 的冲突解决方法 [ZT]JScript下Array对象的性能问题 获取地区的Resolve Weather Location ID Using .NET C# LDAP Library(Novell.Directory.Ldap) WINDOWS下搭建LDAP服务器 [转帖]LDAP Schema的概念和基本要素
Druid中配置双数据库
wingfay · 2018-05-04 · via 博客园 - wingfay

配置如下

<?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:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util-3.2.xsd"
    default-autowire-candidates="byType">

<!--  
单数据源 
 -->
 <!-- 
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
        init-method="init" destroy-method="close">
        <property name="driverClassName">
            <value>${dbDriver}</value>
        </property>
        <property name="url">
            <value>${dbUrl}</value>
        </property>
        <property name="username">
            <value>${dbUsername}</value>
        </property>
        <property name="password">
            <value>${dbPassword}</value>
        </property>
        <property name="maxActive">
            <value>${maxActive}</value>
        </property>
        <property name="initialSize">
            <value>${initialSize}</value>
        </property>
        <property name="maxWait">
            <value>${maxWait}</value>
        </property>
        <property name="minIdle">
            <value>${minIdle}</value>
        </property>
        <property name="removeAbandoned">
            <value>${removeAbandoned}</value>
        </property>
        <property name="removeAbandonedTimeout">
            <value>${removeAbandonedTimeout}</value>
        </property>
        <property name="connectionProperties">
            <value>${connectionProperties}</value>
        </property>
        <property name="logAbandoned" value="true" />
    </bean>
    
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
        p:dataSource-ref="dataSource" p:configLocation="classpath:common/mybatis-config.xml"
        p:mapperLocations="classpath*:common/mapper/**/*.xml" />
         -->
    <!-- mybatis.spring自动映射 -->
    <!--
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="com.niko.dao" p:sqlSessionFactoryBeanName="sqlSessionFactory" />

    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource" />

    <tx:annotation-driven transaction-manager="transactionManager" />
     -->
     
     <!-- 多数据源 mysql 和 sqlserver 共存 -->
     
    <bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.sqlserver.driver}"/>
        <property name="url" value="${jdbc.sqlserver.url}"/>
        <property name="username" value="${jdbc.sqlserver.username}"/>
        <property name="password" value="${jdbc.sqlserver.password}"/>
        <property name="initialSize" value="${jdbc.initialSize}"/>
        <property name="minIdle" value="${jdbc.minIdle}"/>
        <property name="maxIdle" value="${jdbc.maxIdle}"/>
        <property name="maxActive" value="${jdbc.maxActive}"/>
        <property name="maxWait" value="${jdbc.maxWait}"/>
        <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>
        <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>
        <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>
        <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>
        <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>
        <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>
        <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/>
    </bean>
    <bean id="mySqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.mysql.driver}"/>
        <property name="url" value="${jdbc.mysql.url}"/>
        <property name="username" value="${jdbc.mysql.username}"/>
        <property name="password" value="${jdbc.mysql.password}"/>
        <property name="initialSize" value="${jdbc.initialSize}"/>
        <property name="minIdle" value="${jdbc.minIdle}"/>
        <property name="maxIdle" value="${jdbc.maxIdle}"/>
        <property name="maxActive" value="${jdbc.maxActive}"/>
        <property name="maxWait" value="${jdbc.maxWait}"/>
        <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>
        <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>
        <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>
        <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>
        <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>
        <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>
        <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/>
    </bean>
    
    
    <bean id="sqlserverSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" 
        p:dataSource-ref="sqlServerDataSource"
        p:configLocation="classpath:common/mybatis-config.xml"
        p:mapperLocations="classpath*:common/mapper/**/*.xml">
    </bean>
    
       <bean id="mysqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" 
           p:dataSource-ref="mySqlDataSource"
        p:configLocation="classpath:common/mybatis-config.xml"
        p:mapperLocations="classpath*:common/mapper/**/*.xml">
    </bean>
    

    <!-- mybatis.spring自动映射 -->
    <bean id="sqlserverMSF"  class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="com.niko.dao.sqlserver" p:sqlSessionFactoryBeanName="sqlserverSessionFactory" />
        
    <bean id="mysqlMSF"  class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="com.niko.dao.mysql" p:sqlSessionFactoryBeanName="mysqlSessionFactory" />

    <bean id="transactionManagerSqlserver"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="sqlServerDataSource" />

    <bean id="transactionManagerMysql"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="mySqlDataSource" />
        
    <tx:annotation-driven transaction-manager="transactionManagerSqlserver" />
    <tx:annotation-driven transaction-manager="transactionManagerMysql" />

</beans>