spring AOP 配置节选

<?xml version="1.0" encoding="UTF-8"?>

<bean id="accountService" class="com.itheima.service.impl.AccountService"></bean>

<bean id="logger" class="com.itheima.utils.Logger"></bean>


<!-- 1、将通知的bean导入给spring来管理
     2、使用给aop:config 表明开始了 aop 配置
     3、使用 aop:aspect 标签表面切面
        id属性:给切面提供一个唯一标识
        ref属性:指定通知类的bean的id
    4、aop:aspect  配置通知类型
    aop:before
    pointcut 属性:用于指定切入点表达式,对业务层的哪些方法增强 ,
    public void com.itheima.service.impl.AccountServiceImpl.saveAccount()
   访问修饰符可以省略
    void com.itheima.service.impl.AccountServiceImpl.saveAccount()
    返回值可以使用通配符
    * com.itheima.service.impl.AccountServiceImpl.saveAccount()
    包名可以使用通配符,有几个包写几个


    全通配写法
    * *..*.*(..)

    切到业务层实现类
    * com.itheima.service.impl.*.*(..)
 -->
<aop:config>
    <aop:aspect id="logAdvice" ref="logger">
     <aop:before method="printLog" pointcut="execution(public void com.itheima.service.impl.AccountService.saveAccount())"></aop:before>-->
        <aop:before method="printLog" pointcut="execution(    * *..*.*(..))"></aop:before>

    </aop:aspect>
</aop:config>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值