目录
一、AOP的注解的配置入门
1.创建项目引入jar包
2.引入配置文件
(比较全的)
<?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:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
</beans>
3.编写目标类并交给spring管理
4.编写切面类并配置
5.用注解的方法对目标类进行增强
(1)开启注解aop的开发
(2)确定切面类
(3)设置通知的类型
6.编写测试类
(要引入响应的jar包)
详细看 https://mp.csdn.net/postedit/88734267
二、AOP的不同通知类型的使用
1.后置通知@AfterReturning
拿到结果:获取方法的返回值(目标类的具体的方法)
2.前置通知@Before
见上面入门
3.环绕通知@Around
4.异常抛出通知@AfterThrowing
5.最终通知@After
三、AOP注解的切点的配置
1.一个方法(切点)同时要多个状态类类型时
以后要修改时只需要维护切点就ok了