spring + jtom 事务控制

 <?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">

    <!-- 引入jdbc配置文件 -->
    <context:property-placeholder location="classpath:conf/jdbc.properties"/>    
    <context:component-scan base-package="com.demo.*"/>
    <!-- 用于获得spring上下文 -->
    <bean id="springContextUtil" class="com.demo.util.SpringContextUtil" />     

    <!-- JTA事务 -->
    <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>  

    <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager">  
        <property name="userTransaction" ref="jotm" />  
    </bean>  
    <tx:annotation-driven mode="proxy" transaction-manager="txManager" />

    <!--创建数据源dataSource-->
    <bean id="dataSource1" class="org.apache.commons.dbcp2.BasicDataSource">
        <property name="driverClassName" value="${jdbc_driverClassName}" />
        <property name="url" value="${jdbc_url}" />
        <property name="username" value="${jdbc_username}" />
        <property name="password" value="${jdbc_password}" />
    </bean>

    <!--创建数据源dataSource2 -->
    <bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${db2.driver}" />
        <property name="url" value="${db2.url}" />
        <property name="username" value="${db2.username}" />
        <property name="password" value="${db2.password}" />
    </bean>

    <!-- JTA Test begin -->
    <bean id="template1" class="org.springframework.jdbc.core.JdbcTemplate">  
        <property name="dataSource" ref="dataSource1" />  
    </bean>    
    <bean id="template2" class="org.springframework.jdbc.core.JdbcTemplate">  
        <property name="dataSource" ref="dataSource2" />  
    </bean>        
    <!-- JTA Test begin -->
</beans>

没有这个类JotmFactoryBean我知道,我想问的是怎么解决谢谢





1:spring3.0之后不再支持jtom[jta]了,第三方开源软件atomikos(http://www.atomikos.com/)来实现.