问题
I have a class aspectJ in my maven project whitch hepls me to show the Begin and the End of any called method in my project.
I try now to exclude all getters and setters.
I try modify this annotation:
@Around("execution(public * *(..))
by
@Around("execution(public * *(..) && !within(* set*(..))")
But it doesn't whork and it gives me that in the consol:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.7:compile (default) on project spb-lceb: AJC compiler errors:
[ERROR] error at @Around("execution(public * *(..) && !within(* set*(..))")
Syntax error on token "execution(public * *(..) && !within(* set*(..))", ")" expected
Any idea
回答1:
I think it's only a typo because you have a mising ) at the end of the execution call before the && operator:
@Around("execution(public * *(..) && !within(* set*(..))")
Should be:
@Around("execution(public * *(..)) && !within(* set*(..))")
Try it, that should do the trick.
And for the methods that begins with Get the best solution is to rename them to get rid of this conflict.
回答2:
The accepted solution is clearly wrong because within(* set*(..)) will not even compile. This pointcut type needs a type signature, not a method signature. Furthermore, it only tries to take care of setters, not getters as asked by the OP.
The correct solution is:
@Around("execution(public * *(..)) && !execution(* set*(..)) && !execution(* get*(..))")
By accepting the wrong solution the OP even irritated someone else trying is here. This is why after such a long time I am writing this answer.
来源:https://stackoverflow.com/questions/28297095/how-can-i-exclude-getters-and-setters-in-aspectj