Spring基于注解的AOP的切面优先级

每一个切面都有一个默认的优先级(默认值为Integer的最大值)

@Order(1)通过这个注解设置一个正整数数值,数值越小,优先级越高

@Component
@Aspect//将当前组件标识为切面
@Order(1)
public class ValidateAspect {
    //@Before("execution(* com.javasm.spring.aop.annotation.CalculatorImpl.*(..))")
    @Before("com.javasm.spring.aop.annotation.LoggerAspect.pointCut()")
    public void beforMethod(){
        System.out.println("ValidateAspect-->前置通知");
    }
}
posted @ 2022-09-15 16:55  别亦难  阅读(194)  评论(0)    收藏  举报