SpringAop方法执行顺序
- BeforeAround
- before
- 实际方法
- AfterReturn
- After
- AfterAround
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
* @author 青韵
* @date 2020/9/2 - 9:21
*/
@Component
@Aspect
@Order(2)
public class AopTest {
@Pointcut("execution(public void aop.Test.*(..))")
public void pointCut() {
}
@Before("pointCut()")
public void before() {
System.out.println("before...");
}
@AfterReturning("pointCut()")
public void afterReturn() {
System.out.println("after.return...");
}
@After("pointCut()")
public void after() {
System.out.println("after...");
}
@AfterThrowing("pointCut()")
public void aftThr() {
System.out.println("出错");
}
@Around("pointCut()")
public void around(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("before around----");
joinPoint.proceed();
System.out.println("after around----");
}
}