Bean named 'transactionManager'

2020-01-09  本文已影响0人  吃伏冒有礼貌

用Eclipse重新配置spring基于xml的声明式事务时报了这个错.


Bean named 'transactionManager' is expected to be of type 'org.aopalliance.aop.Advice' but was actually of type 'org.springframework.jdbc.datasource.DataSourceTransactionManager'

以为是不熟练Eclipse的配置导致的,找了很久.
最后认真看了看报错消息,名为'transactionManager'的bean 属于<aop:advice>里(我是这么理解的)

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'transactionManager' is expected to be of type 'org.aopalliance.aop.Advice' but was actually of type 'org.springframework.jdbc.datasource.DataSourceTransactionManager'
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:392)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.aop.support.AbstractBeanFactoryPointcutAdvisor.getAdvice(AbstractBeanFactoryPointcutAdvisor.java:116)
    at org.springframework.aop.aspectj.AspectJProxyUtils.isAspectJAdvice(AspectJProxyUtils.java:67)
    at org.springframework.aop.aspectj.AspectJProxyUtils.makeAdvisorChainAspectJCapableIfNecessary(AspectJProxyUtils.java:49)
    at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.extendAdvisors(AspectJAwareAdvisorAutoProxyCreator.java:95)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:96)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:76)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:349)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:301)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:434)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1749)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:576)
    ... 39 more

找到bean.xml,我在建立切入点与事务通知的关系的时候在ref里填入的事务管理器,实际上这是填通知类的,而通知类是 txadvice,很显然我引用错误,


transactionManager是事务管理器不是事务的通知

修改后就解决了


txadvice是事务的通知,它引用了事务管理器
上一篇下一篇

猜你喜欢

热点阅读