问题
I'm trying to implement a Pointcut for spring AOP. All the methods which are like getXXXX
should be logged. I tried the following but either they throw exception or does not trigger:
1st try
@Pointcut("within(net.services.*.get*)")
private void clServiceLayer() {}
@Pointcut("within(net.services.*.get*(..))")
private void clServiceLayer() {}
Need help with the proper expression for point cut.
回答1:
within
limits matching to join points within certain types. Instead you should use execution
Pointcut Designator for matching method execution join points:
@Pointcut("execution(* net.tds.adm.metasolv.customerlink.services.*.get*(..))")
Checkout the Spring Documentation for more detailed discussion.
来源:https://stackoverflow.com/questions/37448480/spring-aop-pointcut-with-method-name-starting-with-get