1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| package com.example.demo.aspect;
import java.util.Iterator;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Component;
@Component @Aspect
public class MyAspect {
@Pointcut(value = "execution(* com.example.demo.service.*.*(..))") public void pc() { }
@AfterThrowing(pointcut = "pc()", throwing = "throwable") public void errFun(Throwable throwable) { System.out.println("exception"); } }
|