Spring AOP切入点,方法名称以get开头 [英] Spring AOP Pointcut with method name starting with get

查看:308
本文介绍了Spring AOP切入点,方法名称以get开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Spring AOP实现切入点.应该记录所有类似于getXXXX的方法.我尝试了以下操作,但是它们抛出异常或不触发:

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:

第一次尝试

@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.

推荐答案

within将匹配限制为某些类型内的连接点.相反,您应该使用execution Pointcut Designator 来匹配方法执行连接点:

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*(..))")

检出 Spring文档进行更详细的讨论.

Checkout the Spring Documentation for more detailed discussion.

这篇关于Spring AOP切入点,方法名称以get开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆