Basic AOP program throws BeanCurrentlyInCreationException

大兔子大兔子 提交于 2019-11-29 14:46:31

I tried with the same piece of code mentioned in the post and defined the Bean in Config.java and it worked for me. The only error i got using this program is in the MyAspect class the

'advice must be public'

@Before("anyPublicOperation()")
public void beforePointCut(){
    System.out.println("Inside before pointcut of MyAspect");
}

Rest executed fine. Also you could try the previous code by refreshing the context before using

ApplicationContext context = new AnnotationConfigApplicationContext();
((AnnotationConfigApplicationContext) context).register(Config.class);
((AbstractApplicationContext) context).refresh(); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!