<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:bean="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--开启组件扫描--> <context:component-scan base-package="com.atguigu.Aop.xmlAop" ></context:component-scan> <!--配置aop五种控制类型--> <aop:config> <!--配置前面类--> <aop:aspect ref="logAspect"> <!--配置切入点--> <aop:pointcut id="pointcut" expression="execution(* com.atguigu.Aop.xmlAop.CalculatorImpl.*(..))"/> <!--配置五种通知类型--> <!--前置通知--> <aop:before method="beforeMethod" pointcut-ref="pointcut"></aop:before> <!--后置通知--> <aop:after method="afterMethod" pointcut-ref="pointcut"></aop:after> <!--返回通知 returning 返回值 --> <aop:after-returning method="returningMethod" returning="result" pointcut-ref="pointcut"></aop:after-returning> <!--异常通知 throwing 表示异常--> <aop:after-throwing method="throwingMethod" throwing="ex " pointcut-ref="pointcut"></aop:after-throwing> <!--环绕通知--> <aop:around method="aroundMethod" pointcut-ref="pointcut"></aop:around> </aop:aspect> </aop:config> </beans>
标签:SpringAOP,xml,基于,五种,通知 From: https://www.cnblogs.com/zhbx/p/17965125