*/
@Aspect
public aspect MyAspect {
@Pointcut("execution(* com.example.demo.controller..*(..))")
public void performance(){}
@Before("performance()")
public void performanceBefore(){
System.out.println("Before");
}
@AfterReturning("performance()")
public void performanceAfterReturning(){
System.out.println("AfterReturning");
}
@After("performance()")
public void performanceAfter(){
System.out.println("After");
}
@AfterThrowing("performance()")
public void performanceAfterThrowing(){
System.out.println("AfterThrowing");
}
@Around("performance()")
public void performanceAround(ProceedingJoinPoint jp){
try {
System.out.println("Around");
//继续执行之后代码
jp.proceed();
} catch (Exception e) {
e.printStackTrace();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
spring中切面
最新推荐文章于 2023-12-05 16:53:42 发布