spring版本4.3.10,mybatis版本3.2.0,atomikos版本4.0.4,整合atomikos,需要额外引入以下两个jar包
<dependency>
<groupId>com.atomikos</groupId>
<artifactId>transactions-jdbc</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<?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:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd "
default-lazy-init="true">
<context:component-scan base-package="com.zhitengda">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<bean id="abstractXADataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean"
init-method="init" destroy-method="close" abstract="true">
<property name="xaDataSourceClassName" value="oracle.jdbc.OracleDriver" />
<property name="minPoolSize" value="10" />
<property name="maxPoolSize" value="30" />
<property name="borrowConnectionTimeout" value="60" />
<property name="reapTimeout" value="20" />
<!-- 最大空闲时间 -->
<property name="maxIdleTime" value="60" />
<property name="maintenanceInterval" value="60" />
<property name="loginTimeout" value="60" />
<property name="testQuery">
<value>select 1</value>
</property>
</bean>
<bean id="qadataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<!-- value只要两个数据源不同就行,随便取名 -->
<property name="poolSize" value="10" />
<property name="uniqueResourceName" value="qa" />
<property name="driverClassName">
<value>oracle.jdbc.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="devdataSource" class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<!-- value只要两个数据源不同就行,随便取名 -->
<property name="uniqueResourceName" value="dev" />
<property name="poolSize" value="10" />
<property name="driverClassName">
<value>oracle.jdbc.OracleDriver</value>
</property> <property name="url">
<value>jdbc:oracle:thin:@127.0.0.1:1521:orcl</value>
</property>
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>