基本概念

  1. Aspect切面:就是那个加了@Aspect的类

    1. @Aspect
    2. @Component
    3. public class Logger {
    4. @Pointcut("execution(public void com.example.firstspringboot.service.*.*(..))")
    5. public void pointCut() {
    6. }
    7. @Before(value = "pointCut()")
    8. public void logBefore() {
    9. System.out.println("================= Log before =================");
    10. }
    11. }
  2. 切入点:就是@Pointcut注解,就是要在哪些方法上面进行增强

    1. @Pointcut("execution(public void com.example.firstspringboot.service.*.*(..))")
  3. 通知:就是整个要被调用的方法,用@Before, @After 等标注

    1. @Before(value = "pointCut()")
    2. public void logBefore() {
    3. System.out.println("================= Log before =================");
    4. }