@Aspect staticclassBeanAspect{ // orderService 빈과 Repository 로 끝나는 빈들에 Advice 를 적용합니다. @Around("bean(orderService) || bean(*Repository)") public Object doLog(ProceedingJoinPoint joinPoint)throws Throwable { log.info("[bean] {}", joinPoint.getSignature()); return joinPoint.proceed(); } } }
2021-12-21 00:13:43.463 INFO 35836 --- [ Test worker] com.example.aop.pointcut.BeanTest : [bean] void com.example.aop.order.OrderService.orderItem(String) 2021-12-21 00:13:43.474 INFO 35836 --- [ Test worker] com.example.aop.order.OrderService : [orderService] 실행 2021-12-21 00:13:43.475 INFO 35836 --- [ Test worker] com.example.aop.pointcut.BeanTest : [bean] String com.example.aop.order.OrderRepository.save(String) 2021-12-21 00:13:43.480 INFO 35836 --- [ Test worker] com.example.aop.order.OrderRepository : [orderRepository] 실행