Most Spring applications only need a single transaction manager, but there may be situations where you want multiple independent transaction managers in a single application. The value attribute of the @Transactional
annotation can be used to optionally specify the identity of the PlatformTransactionManager
to be used. This can either be the bean name or the qualifier value of the transaction manager bean. For example, using the qualifier notation, the following Java code
public class TransactionalService { @Transactional("order") public void setSomething(String name) { ... } @Transactional("account") public void doSomething() { ... } }
could be combined with the following transaction manager bean declarations in the application context.
<tx:annotation-driven/> <bean id="transactionManager1" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> ... <qualifier value="order"/> </bean> <bean id="transactionManager2" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> ... <qualifier value="account"/> </bean>
In this case, the two methods on TransactionalService
will run under separate transaction managers, differentiated by the "order" and "account" qualifiers. The default <tx:annotation-driven>
target bean name transactionManager
will still be used if no specifically qualified PlatformTransactionManager bean is found.
참조 URL : https://www.lesstif.com/pages/viewpage.action?pageId=20774954
'JAVA오픈소스 > Spring' 카테고리의 다른 글
파라매터들이 리스트로 왔을떄 처리법 (0) | 2016.12.20 |
---|---|
ApplicationContext 싱글톤으로 만들기 (0) | 2016.01.28 |
트렌젝션 사용자 commit (0) | 2015.12.04 |
파라메터(parameter) 어노테이션 및 객체 정보 및 설명 (0) | 2015.11.17 |
static 변수 Autowired 하기 (0) | 2015.07.16 |