xml方式AOP快速入门

xml方式配置AOP的步骤

  1. 导入AOP相关坐标

  2. 准备目标类和通知类, 并配置给Spring管理

  3. 配置切点表达式(哪些方法被增强)

  4. 配置织入(切点被哪些通知方法增强, 是前置增强还是后置增强)

1
2
3
4
5
6
7
8
9
10
<bean id="userService" class="com.nju.service.impl.UserServiceImpl"/>

<bean id="myAdvice" class="com.nju.advice.MyAdvice"/>

<aop:config>
<aop:pointcut id="myPointcut" expression="execution(void com.nju.service.impl.UserServiceImpl.show1())"/>
<aop:aspect ref="myAdvice">
<aop:before method="beforeAdvice" pointcut-ref="myPointcut"/>
</aop:aspect>
</aop:config>

xml方式AOP配置详解

image-20250127173249637

image-20250127173610471

image-20250127174107507

image-20250127174408535

image-20250127175501798

xml方式AOP原理剖析

image-20250127190742357