Basic AOP program throws BeanCurrentlyInCreationException

前端 未结 1 898
一生所求
一生所求 2020-12-21 05:01

I am creating a simple AOP program and starting getting BeanCurrentlyInCreationException exception with it.

Here is my code:

MyAspect.ja

相关标签:
1条回答
  • 2020-12-21 05:34

    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(); 
    
    0 讨论(0)
提交回复
热议问题