在配置多数据源时,在有持久化操作的时候,aop拦截该方法,然后进行路由数据源操作,启动项目,就报如下异常(只提出了重要提示信息),而把aop配置注掉就没事了
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.company.exer.dao.SysLogDao] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
经排查原因:在xml中要加一行这个配置<aop:aspectj-autoproxy proxy-target-class="true"/>
而proxy-target-class默认属性是false,当属性为true时,强制使用CGLIB动态代理方式,false时为JDK动态代理。(动态代理原理还没有弄明白,有待学习完动态代理知识后,更新此博客)