<?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"
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-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
"> <!-- ====================数据源1==================== -->
<!-- sql会话模版 -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory" />
</bean>
<!-- 配置mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis1/mybatis-config.xml"></property>
<!-- mapper扫描 -->
<property name="mapperLocations" value="classpath:mybatis1/*/*.xml"></property>
</bean>
<!-- 阿里 druid数据库连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<!-- 数据库基本信息配置 -->
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<property name="driverClassName" value="${driverClassName}" />
<property name="filters" value="${filters}" />
<!-- 最大并发连接数 -->
<property name="maxActive" value="${maxActive}" />
<!-- 初始化连接数量 -->
<property name="initialSize" value="${initialSize}" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="${maxWait}" />
<!-- 最小空闲连接数 -->
<property name="minIdle" value="${minIdle}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
<property name="validationQuery" value="${validationQuery}" />
<property name="testWhileIdle" value="${testWhileIdle}" />
<property name="testOnBorrow" value="${testOnBorrow}" />
<property name="testOnReturn" value="${testOnReturn}" />
<property name="maxOpenPreparedStatements" value="${maxOpenPreparedStatements}" />
<!-- 打开removeAbandoned功能 -->
<property name="removeAbandoned" value="${removeAbandoned}" />
<!-- 1800秒,也就是30分钟 -->
<property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" />
<!-- 关闭abanded连接时输出错误日志 -->
<property name="logAbandoned" value="${logAbandoned}" />
</bean>
<!-- 事物处理 -->
<aop:config>
<aop:pointcut id="pc" expression="execution(* com.cd.service..*(..))" />
<aop:advisor pointcut-ref="pc" advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception"/>
<tx:method name="insert*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
<tx:method name="update*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
<tx:method name="save*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
</tx:attributes>
</tx:advice>
<bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- enable transaction annotation support -->
<tx:annotation-driven transaction-manager="transactionManager" /> <!-- ====================数据源2==================== -->
<!--
<bean id="sqlSessionTemplate2" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory2" />
</bean>
<bean id="sqlSessionFactory2" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="configLocation" value="classpath:mybatis2/mybatis-config.xml"></property>
<property name="mapperLocations" value="classpath:mybatis2/*/*.xml"></property>
</bean>
<bean id="dataSource2" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="url" value="${url2}" />
<property name="username" value="${username2}" />
<property name="password" value="${password2}" />
<property name="driverClassName" value="${driverClassName2}" />
<property name="filters" value="${filters2}" />
<property name="maxActive" value="${maxActive2}" />
<property name="initialSize" value="${initialSize2}" />
<property name="maxWait" value="${maxWait2}" />
<property name="minIdle" value="${minIdle2}" />
<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis2}" />
<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis2}" />
<property name="validationQuery" value="${validationQuery2}" />
<property name="testWhileIdle" value="${testWhileIdle2}" />
<property name="testOnBorrow" value="${testOnBorrow2}" />
<property name="testOnReturn" value="${testOnReturn2}" />
<property name="maxOpenPreparedStatements" value="${maxOpenPreparedStatements2}" />
<property name="removeAbandoned" value="${removeAbandoned2}" />
<property name="removeAbandonedTimeout" value="${removeAbandonedTimeout2}" />
<property name="logAbandoned" value="${logAbandoned2}" />
</bean>
<aop:config>
<aop:pointcut id="pc2" expression="execution(* com.cd.service..*(..))" />
<aop:advisor pointcut-ref="pc2" advice-ref="txAdvice2" />
</aop:config>
<tx:advice id="txAdvice2" transaction-manager="transactionManager2">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception"/>
<tx:method name="insert*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
<tx:method name="update*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
<tx:method name="save*" propagation="REQUIRED" read-only="false"
rollback-for="java.lang.Exception" />
</tx:attributes>
</tx:advice>
<bean name="transactionManager2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource2"></property>
</bean>
-->
<!-- qq -->
</beans>

最新文章

  1. sqlserver数据库标注为可疑的解决办法(转)
  2. (转)使用Node.js+Socket.IO搭建WebSocket实时应用
  3. 【EF学习笔记05】----------DBContext基础查询
  4. Gradle自定义你的BuildConfig
  5. LBS由ip查经纬度
  6. Error opening trace file: No such file or directory (2)
  7. 【原】centos6.5下cdh4.6 Oozie安装
  8. ubuntu下安装xlrd模块,Mysqldb模块
  9. SQL Server 查看表定义的 2 种方法
  10. SQLServer 中实现类似MySQL中的group_concat函数的功能
  11. Ajax应用常见的HTTP ContentType设置
  12. 01-oracle学习环境配置
  13. Spark之submit任务时的Initial job has not accepted any resources; check your cluster UI to ensure that workers are registered and have sufficient memory
  14. 实现strStr()的golang实现
  15. IIS(互联网信息服务)
  16. MATLAB中 histogram 和 imhist 的区别
  17. C# 字符串处理小工具
  18. SSM框架——实现分页和搜索分页
  19. c# 读取网卡Mac
  20. unity linear work flow

热门文章

  1. Python线程二
  2. VLC添加水印
  3. python图片识别
  4. ueditor自定义额外参数
  5. shell test判断命令
  6. centos7.0 64位系统 安装PHP5.3 支持 nginx
  7. Ubuntu16.04无法使用WiFi
  8. .net core 之Hangfire任务调度
  9. Centos防火墙设置与端口开放的方法
  10. vsts 管理 持续集成 跟自动化测试