@Pointcut表达式自宫记录 Is there an unresolvable circular reference?

今天要写一个Spring的切面测试,本意是想一刀切到所在bean的包下,然后查看这些bean被代理的情况。由于是测试环境,我图省事儿就把所有的class都放在同一个路径下了,然后BlueAspect切面中的pointcut表达式直接切向了slg.aop.aspect包下的所有类。
在这里插入图片描述
结果直接带来了血淋淋的后果:

nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘blueAspect’ defined in com.enjoy.slg.aop.MyConfig3: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.enjoy.slg.aop.BlueAspect]: Factory method ‘blueAspect’ threw exception; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘blueAspect’: Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1254)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1103)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:88)
at com.enjoy.slg.aop.MyConfig3.main(MyConfig3.java:33)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.enjoy.slg.aop.Book]: Factory method ‘book’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘blueAspect’ defined in com.enjoy.slg.aop.MyConfig3: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.enjoy.slg.aop.BlueAspect]: Factory method ‘blueAspect’ threw exception; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘blueAspect’: Requested bean is currently in creation: Is there an unresolvable circular reference?
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
… 13 more

因为这个pointcut不光切了我想要代理的bean,也同时毫不留情的把刀挥向了自己(Aspect类也在slg.aop.aspect这个包下)……所以说练功需谨慎,没事儿别自宫

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值