(基于xml配置Aop)学习Spring的第十五天

一 . Spring Aop编程简介

 再详细点 , 如下

二 . 基于xml配置Aop 

解决proxy相关问题

 

 解决问题开始用xml配置AOP

导入pom坐标

         <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.9.6</version>
         </dependency>

由于2做过, 我们直接展示3 ,4

这是一个基本的对show1()增强的案例

<aop:aspect ref="myAdvice">
            <!--前置通知-->
            <aop:before method="beforeAdvice" pointcut-ref="myPointcut"/>
        </aop:aspect>

上面这段代码表示对show1()进行前置增强

<!--aop配置-->
    <aop:config proxy-target-class="true">
        <!--配置切点表达式,目的是要指定哪些方法被增强-->
        <aop:pointcut id="myPointcut" expression="execution(void com.itheima.service.impl.UserServiceImpl.show1())"/>
<!--        <aop:pointcut id="myPointcut2" expression="execution(* com.itheima.service.impl.*.*(..))"/>-->
        <!--配置织入,目的是要执行哪些切点与那些通知进行结合-->
        <aop:aspect ref="myAdvice">
            <!--前置通知-->
            <aop:before method="beforeAdvice" pointcut-ref="myPointcut"/>
        </aop:aspect>

    </aop:config>

三 . xml方式配置AOP详解

3.1以下为切点表达式简介

来看几个例子

 3.2 以下为通知类型(织入表达式的配置)

相关推荐

  1. 学习Spring

    2024-02-08 01:50:01       35 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-08 01:50:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-08 01:50:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-08 01:50:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-08 01:50:01       18 阅读

热门阅读

  1. 分支解决冲突 & 分支管理策略 git merge命令详解

    2024-02-08 01:50:01       31 阅读
  2. 【Git】三棵“树”介绍

    2024-02-08 01:50:01       34 阅读
  3. (39)统计位数为偶数的数字

    2024-02-08 01:50:01       36 阅读
  4. work day7

    2024-02-08 01:50:01       27 阅读
  5. PyTorch自动微分模块torch.autograd的详细介绍

    2024-02-08 01:50:01       31 阅读
  6. 蓝桥杯-“山”形数字个数(python版)

    2024-02-08 01:50:01       33 阅读