spring aop学习笔记

依赖:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
        
</beans>

spring中基于XML的AOP配置步骤:

1、把通知Bean交给spring来管理

2、使用aop:config标签表明开始AOP的配置

3、使用aop:aspect标签表明配置切面

    id属性:给切面提供一个唯一标识

    ref属性:指定通知类bean的id

4、在aop:aspect标签内部使用对应标签配置通知类型

    aop:before,表示配置前置通知。

      method属性:用于指定通知类中哪个方法是前置通知。

      pointcut属性:用于指定切入点表达式。表达式含义:对业务层哪些方法增强。

    切入点表达式写法:

      关键字:execution(表达式)

      表达式:

        访问修饰符  返回值  包名.包名...类名.方法名(参数列表)

      列如:public  void  com.lin.service.AccountServiceImpl.save()

转载于:https://www.cnblogs.com/linyaoguo/p/11583259.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值