spring能不能对多个数据库进行事务管理

2025-03-23 05:11:24
推荐回答(1个)
回答1:

可以,Spring的事务处理能力是最综合完整的,对编程式、声明式均进行了支持,而且可以在不使用应用服务器的情况下兼容应用服务器事务。下面的是一个分布式的声明事务,访问多个数据源的配置:









class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">





classpath*:spring/jdbc.properties








init-method="init" destroy-method="close">









${mysql.user}

${mysql.password}

${mysql.url}










init-method="init" destroy-method="close">









${oracle.user}

${oracle.password}

${oracle.url}












init-method="init" destroy-method="close">


















class="org.springframework.transaction.jta.JtaTransactionManager">
















class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"

abstract="true">











PROPAGATION_REQUIRED, +AuaException