最近遇到个问题,在方法上使用@Transactional,在spring.xml中也配置了事务,
<bean id="portalTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="csportalDataSource" />
</bean>
却报这个错误:
java.lang.IllegalStateException: No matching PlatformTransactionManager bean found for qualifier 'transactionManagerExt' - neither qualifier match nor bean name match!
at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:91)
at org.springframework.transaction.interceptor.TransactionAspectUtils.getTransactionManager(TransactionAspectUtils.java:53)
at org.springframework.transaction.interceptor.TransactionAspectSupport.determineTransactionManager(TransactionAspectSupport.java:245)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
最后才发现没有配置:
<tx:annotation-driven transaction-manager="portalTransactionManager" order="0"/>
<tx:annotation-driven>这个配置的作用是开启注解功能。
transaction-manager指明了事务的来源,order指明了事物的执行优先级,order的值越小,优先级越高