首页 > 其他分享 >Spring23 - 基于XML配置的AOP

Spring23 - 基于XML配置的AOP

时间:2023-02-07 17:33:57浏览次数:40  
标签:XML xml 基于 Spring23 配置 AOP

基于XML的AOP

准备工作

参考基于注解的AOP环境

实现

在 .xml 文件中对 AOP 进行配置

<context:component-scan base-package="com.atguigu.aop.xml"></context:component-scan>

<aop:config>
    <!--配置切面类-->
    <aop:aspect ref="loggerAspect">
        <aop:pointcut id="pointCut" 
                   expression="execution(* com.atguigu.aop.xml.CalculatorImpl.*(..))"/>
        <aop:before method="beforeMethod" pointcut-ref="pointCut"></aop:before>
        <aop:after method="afterMethod" pointcut-ref="pointCut"></aop:after>
        <aop:after-returning method="afterReturningMethod" returning="result" pointcut-ref="pointCut"></aop:after-returning>
        <aop:after-throwing method="afterThrowingMethod" throwing="ex" pointcut-ref="pointCut"></aop:after-throwing>
        <aop:around method="aroundMethod" pointcut-ref="pointCut"></aop:around>
    </aop:aspect>
</aop:config>

标签:XML,xml,基于,Spring23,配置,AOP
From: https://www.cnblogs.com/Ashen-/p/17099234.html

相关文章

  • Spring22 - 基于注解的AOP
    基于注解的AOP技术说明动态代理分为JDK动态代理和cglib动态代理当目标类有接口的情况使用JDK动态代理和cglib动态代理,没有接口时只能使用cglib动态代理JDK动态代理......
  • 数据采集技术之在Python中Libxml模块安装与使用XPath
    为了使用XPath技术,对爬虫抓取的网页数据进行抽取(如标题、正文等等),之后在Windows下安装libxml2模块(安装后使用的是Libxml模块),该模块含有xpath。准备需要的软件包:Python2.7......
  • maven pom.xml
    <!--文件拷贝时的编码jdk版本--><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outp......
  • 实战:第十二章:txt文件转xml文件
    开发不就这么点事吗,有个啥好bb的controller@RequestMapping("/DataDistributionController")@RestControllerpublicclassDataDistributionController{......
  • mybatis的xml文件的传入参数不同的写法
    1、如果是传入多个字符串的参数。parameterType="java.lang.String"<selectid="getMaxNum"parameterType="java.lang.String"resultType="java.lang.Integer">se......
  • 使用注解实现AOP
            ......
  • Aop实现方式一
         ......
  • spring 重复注解和aop拦截的实现示例
    前言:1:jdk1.8开始支持重复注解@Repeatable实现2:aop拦截需要拦截当前注解和@Repeatable指向的包装注解才可以完全拦截到,因为:1.当在在方法上只有一个注解时,aop拦截......
  • 详解Spring AOP自定义可重复注解没有生效问题
    目录1.问题背景2.不啰嗦,上代码3.问题排查3.1是不是切点写得有问题,于是换成如下形式:3.2是不是使用的地方不是代理对象4.问题原因 1.问题背景工作中遇......
  • Spring AOP使用接口方式实现
    目录一.环境准备二、spring接口方式实现aop步骤1.业务接口实现2.业务类3.通知类4.自定义切##点5.配置xml文件6.方法入口三.分析Spring提供了很多的......