执行时机,也就是AOP的执行顺序嘛。了解AOP中aspect的执行顺序,有助于我们更好的使用AOP。
下面我们通过一个见到那的例子去了解AOP的执行顺序。
按照以下顺序使用AOP:
1、添加jar包:
2、添加spring xml文件,在文件中配置,为目标对象生成动态代理对象。如图所示:
配置代码如下:
<?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"
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/