Spring AOP Advice Called Twice
For some reason, my Spring AOP advices are being called twice. I checked:
Spring AOP advice is called twice but I am not using the Component annotation, and am declaring the aspect bean once and annotating it with @Aspect and that's it.
Somewhat belatedly I realized that one of my classes was not implementing an interface yet, which caused CGLIB2 requirements. I fixed that, and the CGLIB2 problem went away, but the double invocation remains.
Edit:
Forgot to mention that I checked, and the method being advised is not called twice.
2nd edit:
I declare a class with @Aspect, and then I declare it as a bean in the application context. There are no advices or pointcuts in the XML file.
3rd edit:
Also worth noting is that I log before and after the execution of the method being advised with Around:
log.info("before");
pjp.proceed();
log.info("after");
What I see is:
before
before
after
after
Which is really weird.
This happens for both @Before and @Around advice that I have set up. I have yet to try the other types.
Here is the pointcut declaration, with changed names:
@Around("execution(public java.util.List<java.lang.String> pac.age.names.myDAO.doSomething(java.lang.String, java.lang.String))")
Any ideas?
Thanks,
Snorkel
Well, it seems like this is actually an issue with the logger. This morning I checked and found that everything is being logged twice. When I replaced logger calls with regular sysout calls, everything worked fine.
链接地址: http://www.djcxy.com/p/77248.html上一篇: Spring aspectj注释切入点
下一篇: 春季AOP建议被称为两次