Tag: spring transactions

spring – 是否有可能在同一个应用程序中使用多个事务pipe理器?

我是Spring的新手,我想知道是否可以在同一个应用程序中使用众多的事务pipe理器? 我有两个数据访问层 – 一个用于两个数据库。 我想知道,你如何去使用一个事务pipe理器的一层和不同的事务pipe理器的另一层。 我不需要在两个数据库之间执行事务。 但我确实需要单独对每个数据库执行事务。 我已经创build了一个图像来帮助概述我的问题: 这是我的应用程序上下文configuration: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/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"> <context:component-scan base-package="cheetah.repositories" /> <tx:annotation-driven /> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> <property name="persistenceUnitName" value="accounts" /> </bean> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> </beans> 以下是使用此configuration的示例: @Repository public class JpaAccountRepository implements AccountRepository { @PersistenceContext(unitName = […]