- 방법 1
<tx:annotation-driven />
<bean id=”transactionManager”
class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”
p:dataSource-ref=”dataSource1”/>
<bean id=”txManager2”
class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”
p:dataSource-ref=”dataSource2”/>
그리고 Service 클래스의 메서드에 선언된 @Transactional 부분도
명시적으로 트랜잭션 매니져를 설정 해야 합니다.
※ “transactionManager” 빈 아이디를 사용할 경우 지정할 필요가 없습니다.
@Transactional
public void createDatasource1() {
//logic….
}
@Transactional(value=”txManager2”)
public void createDatasource2() {
//logic….
}
- 방법2
<tx:annotation-driven transaction-manager=”txManager1" />
<bean id=”txManager1”
class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”
p:dataSource-ref=”dataSource1”/>
<bean id=”txManager2”
class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”
p:dataSource-ref=”dataSource2”/>
@Transactional(value=”txManager1”)
public void createDatasource1() {
//logic….
}
@Transactional(value=”txManager2”)
public void createDatasource2() {
//logic….
}
댓글