execution(modifiers-pattern? ret-type-pattern declaring-type-pattern?
name-pattern(param-pattern) throws-pattern?)

modifiers-pattern:方法的操作权限

ret-type-pattern:返回值【必填】

declaring-type-pattern:方法所在的包

name-pattern:方法名【必填】

parm-pattern:参数名

throws-pattern:异常

目前SpringAOP 配置有两种形式,这个小伙伴们应该都非常清楚,我这里就不做过多赘述,如下Annotation 配置形式:

/*** Annotation版Aspect切面Bean*/
//声明这是一个组件
@Component
//声明这是一个切面Bean
@Aspect
@Slf4j
public class AnnotaionAspect {//配置切入点,该方法无方法体,主要为方便同类中其他方法使用此处配置的切入点@Pointcut("execution(* com.leon.pattern.spring.aop.service..*(..))")public void aspect(){    }/** 配置前置通知,使用在方法aspect()上注册的切入点* 同时接受JoinPoint切入点对象,可以没有该参数*/@Before("aspect()")public void before(JoinPoint joinPoint){log.info("before通知 " + joinPoint);}//配置后置通知,使用在方法aspect()上注册的切入点@After("aspect()")public void after(JoinPoint joinPoint){log.info("after通知  " + joinPoint);}//配置环绕通知,使用在方法aspect()上注册的切入点@Around("aspect()")public void around(JoinPoint joinPoint){long start = System.currentTimeMillis();try {((ProceedingJoinPoint) joinPoint).proceed();long end = System.currentTimeMillis();log.info("around通知 " + joinPoint + "\tUse time : " + (end - start) + " ms!");} catch (Throwable e) {long end = System.currentTimeMillis();log.info("around通知 " + joinPoint + "\tUse time : " + (end - start) + " ms with exception : " + e.getMessage());}}//配置后置返回通知,使用在方法aspect()上注册的切入点@AfterReturning("aspect()")public void afterReturn(JoinPoint joinPoint){log.info("afterReturn通知 " + joinPoint);}//配置抛出异常后通知,使用在方法aspect()上注册的切入点@AfterThrowing(pointcut="aspect()", throwing="ex")public void afterThrow(JoinPoint joinPoint, Exception ex){log.info("afterThrow通知 " + joinPoint + "\t" + ex.getMessage());}}

Xml 配置形式:

<beans xmlns="http://www.springframework.org/schema/beans"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsd"><aop:aspectj-autoproxy proxy-target-class="true"/><bean id="xmlAspect" class="com.leon.pattern.spring.aop.aspect.XmlAspect"></bean><!-- AOP配置 --><aop:config><!-- 声明一个切面,并注入切面Bean,相当于@Aspect --><aop:aspect ref="xmlAspect"><!-- 配置一个切入点,相当于@Pointcut,用来切面规律一种语言 --><aop:pointcut expression="execution(* com.leon.pattern.spring.aop.service..*(..))" id="simplePointcut"/><!-- 配置通知,相当于@Before、@After、@AfterReturn、@Around、@AfterThrowing --><aop:before pointcut-ref="simplePointcut" method="before"/><aop:after pointcut-ref="simplePointcut" method="after"/><aop:after-returning pointcut-ref="simplePointcut" method="afterReturn"/><aop:after-throwing pointcut-ref="simplePointcut" method="afterThrow" throwing="ex"/></aop:aspect></aop:config></beans>

关于Execution 表达式相关推荐

  1. java aop execution_Spring AOP -- execution表达式

    *:匹配任何数量字符: ..:匹配任何数量字符的重复,如在类型模式中匹配任何数量子包:而在方法参数模式中匹配任何数量参数. +:匹配指定类型的子类型:仅能作为后缀放在类型模式后边. 234017_UI ...

  2. spring AspectJ的Execution表达式

    Aspectj切入点语法定义 在使用spring框架配置AOP的时候,不管是通过XML配置文件还是注解的方式都需要定义pointcut"切入点" 例如定义切入点表达式 execut ...

  3. Spring AspectJ Execution 表达式

    1. 定义切点表达式 execution(* com.xinsui.service.impl..*.*(..)) execution(* *..impl..*.*(..)) 切点表达式分为五个部分 1 ...

  4. AspectJ的Execution表达式

    AspectJ的Execution表达式 execution() execution()是最常用的切点函数,其语法如下所示: execution(<修饰符模式>? <返回类型模式&g ...

  5. Spring AOP切入点@Pointcut -- execution表达式

    Spring AOP 切入点@Pointcut – execution表达式 表达式示例 execution(* com.sample.service.impl..*.*(..)) 详述: execu ...

  6. Spring Aspect @PointCut(execution表达式)

    execution(* com.sample.service.impl..*.*(..)) 解释如下: 符号 含义 execution() 表达式的主体: 第一个"*"符号 表示返 ...

  7. 白话Spring(基础篇)---AOP(execution表达式)

    [一知半解,就是给自己挖坑] 作为AOP的最后一节内容,我们来简单总结一下切面表达式上见的书写方法.下面的那内容有参考其他博文,在此先对开源博客的各位大神表示感谢! ----------------- ...

  8. Spring AOP -- execution表达式

    *:匹配任何数量字符: ..:匹配任何数量字符的重复,如在类型模式中匹配任何数量子包:而在方法参数模式中匹配任何数量参数. +:匹配指定类型的子类型:仅能作为后缀放在类型模式后边. 表达式示例 exe ...

  9. execution 表达式用法汇总

    1.切所有controller下的请求 项目结构 任意公共方法的执行: 1 execution(public * (-)) ##public可以省略, 第一个 代表方法的任意返回值 第二个参数代表任意 ...

  10. java execution_aop execution 表达式解析

    execution(* com.sample.service.impl..*.*(..)) 解释如下: 符号含义 execution() 表达式的主体: 第一个"*"符号 表示返回 ...

最新文章

  1. mysql数据库语句q_mysql数据库命令大全,mysql基本命令大全
  2. java des zero_android----Java DES加密算法工具类
  3. 配置管理小报100629:我是项目组成员,事情比较急,按流程需要项目经理批准,但项目经理不在怎么办?...
  4. shiro的简单入门使用
  5. python获取某文件路径_Python获取当前文件路径
  6. mysql mvcc undo_Mysql Innodb中undo-log和MVCC多版本一致性读 的实现
  7. java集合类程序代码_Java集合类源代码分析二:ArrayList(1)
  8. 读《向外行一样思考、像专家一样实践》之 简单、省略、抽象化、例子分析
  9. 【ACL20】让笨重的BERT问答匹配模型变快!
  10. 掌门教育微服务体系 Solar(下)
  11. 异速联服务器配置 虚拟机,异速联 安装教程
  12. 安卓熄屏录像_最屌免费安卓Android屏幕录像软件 (免ROOT)
  13. 程序员客栈 接不到单子_常见(但不常见)单子
  14. 不仅国产手机被撕下遮羞布,其实苹果和三星也已没了遮羞布
  15. 【错误】无法验证是否已安装所需的Microsoft更新KB2919355
  16. 和Xiong的一段对话
  17. STM32F103代码远程升级(五)基于MQTT协议WiFi远程升级代码的实现
  18. 高斯定理的理解——工程电磁场 P2~P5
  19. 条码软件如何调整条形码的密度
  20. MDK5(keil5)源文件列表中黄色的钥匙标识

热门文章

  1. JS中数据结构之队列
  2. MySQL表完整性约束
  3. 使用ML.NET实现猜动画片台词
  4. Scrapy Learning笔记(四)- Scrapy双向爬取
  5. Android调用手机中的应用市场,去评分的功能实现
  6. VC中获取窗体句柄的各种方法
  7. C# 从CIL代码了解委托,匿名方法,Lambda 表达式和闭包本质
  8. yslow客户端性能测试
  9. Hangfire源码解析-如何实现可扩展IOC的?
  10. 【洛谷1361】 小M的作物(最小割)