Spring AOP Pointcut with method name starting with get

若如初见. 提交于 2019-12-23 12:59:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!