AOP知识

本文介绍了AOP的切入点表达式,包括bean、within、execution和@annotation表达式的用法,详细阐述了通知的种类,如前置、后置、异常通知,并解释了代理对象的生成策略,特别指出Spring默认采用的代理方式。
摘要由CSDN通过智能技术生成

1.切入点表达式

1.1bean表达式

说明:根据bean的ID拦截指定对象

 @Pointcut("bean(userServiceImpl)")
    public void pointcut(){

    }

1.2within表达式

说明:按照类型匹配,可以使用通配符"*"

1.@Pointcut("within(com.jt.service.UserServiceImpl)")
只拦截UserServiceImpl的类

2.@Pointcut("within(com.jt.service.*)")
只拦截com.jt.service下所有的类


3.@Pointcut("within(com.jt.service..*)")
拦截com.jtservice下所有包下的所有类


4.@Pointcut("within(com.*.service..*)")
以com开头service下的所有包下的所有类

说明:上述得2种操作方法粒度较粗,一般情况不用了.

1.3execution表达式

作用:粒度比较细,可以按照方法参数进行匹配.

语法:

        

@Pointcut("execution(返回值 包名.类名.方法名(参数列表))")

1.按照类型方法匹配

@Pointcut("execution(* com.jt.service.UserSer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值