@Slf4j
@Aspect
@Component
public class ConfigAop {
@Pointcut("execution(..............*(..))")
public void configPoint() {
}
@Before(value = "configPoint()")
public void before(JoinPoint joinPoint) {
System.out.println("[Aspect1] before advise");
}
@Around(value = "configPoint()")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("[Aspect1] around advise 1");
Object proceed = pjp.proceed();
System.out.println("[Aspect1] around advise2");
return proceed;
}
@AfterReturning(value = "configPoint()")
public void afterReturning(JoinPoint joinPoint) {
System.out.println("[Aspect1] afterReturning advise");
}
@AfterThrowing(value = "configPoint()")
public void afterThrowing(JoinPoint joinPoint) {
System.out.println("[Aspect1] afterThrowing advise");
}
@After(value = "configPoint()")
public void after(JoinPoint joinPoint) {
System.out.println("[Aspect1] after advise");
}
}
spring aop 使用
最新推荐文章于 2024-01-08 09:45:46 发布