I was trying to follow this video tutorial to add AOP to my Spring Boot project in order to perform log operation:
So what is wrong? What am I missing? How can I try to fix it?
CodePudding user response:
Your pointcut
execution(* com.easydefi.users.*.*.*(..))
looks a bit unflexible, but it works perfectly for intercepting methods like
public void com.easydefi.users.service.CoinService.doSomething()
public boolean com.easydefi.users.specification.MySpec.fooBar(int, String)
It works not for
public String com.easydefi.users.specification.criteria.MyCriteria.zot()
public void com.easydefi.users.aa.bb.cc.SomeService.zot()
for reasons M. Deinum has mentioned already. His suggestion to use the ..*
notation, which means "any method in any class in the package preceded by ..*
", is exactly right:
execution(* com.easydefi.users..*(..))
I also want to stress that the credit for this answer should be his, and if he likes to simply copy my answer and post it under his own name instead of just a comment, I shall remove this one gladly instead. But I do think questions deserve comprehensive answers.