이제 실제 spring boot 에서 #AOP 를 구현하는 방법에 대해 알아보겠습니다. 가장 간단한 형태는 아래와 같습니다.
@Aspect 를 넣어서 advisor 대상임을 표시하고 @Component를 통해 빈으로 등록합니다. @Around 를 통해 pointcut 을 지정해주고 바로 아래 메서드를 통해 advice 를 정의합니다.
@Slf4j @Aspect @Component public class LogAspect { @Around("execution(public * dev.developery.mdc.reflection..*(..))") public Object advice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { StopWatch sw = new StopWatch(); sw.start(); ////// 여기가 원본 target ////////// Object result = proceedingJoinPoint....
#
AfterReturning
#
AOP
#
Around
#
Before
#
After
#
AfterThrowing