spring

TransactionManager가 2개 일 때 (expected single matching bean but found 2)

마이스프링 2014. 5. 23. 16:41

TransactionManager가 2개 일 때 (expected single matching bean but found 2)


심각: Servlet.service() for servlet [dispatcher] in context with path [/spring32] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 2: jpaTransactionManager,transactionManager] with root cause

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.springframework.transaction.PlatformTransactionManager] is defined: expected single matching bean but found 2: jpaTransactionManager,transactionManager

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:289)

at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:334)

at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:250)

at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)

at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)

at com.sun.proxy.$Proxy28.getAccount(Unknown Source)


TransactionManager가 2개 라서 그런 것 같다.


@Transactional 이 있는 곳에서 명시적으로 설정하면 된다.

@Transactional("jpaTransactionManager")

@Transactional(value = "transactionManager")

@Transactional(value = "transactionManager", readOnly = true, propagation=Propagation.SUPPORTS)


9.


10.