Spring Boot / Part 8YOUTUBE PLAYER LOADS ON PLAYTime any method with AOP
@Around

Spring Boot AOP: Log Method Execution Time with @Around & a Custom Annotation

Spring Boot11 Oct 20246:38Open on YouTube

In this lesson

Adding start/end timers to every method just to see how long it takes? With Spring AOP you write that logic once and apply it to any method with a single custom annotation: @LogExecutionTime.

  • Creating a custom @LogExecutionTime annotation
  • What @Target(ElementType.METHOD) and @Retention(RUNTIME) actually do
  • Building an Aspect with @Aspect + @Component
  • Using @Around advice to intercept annotated methods
  • Measuring and logging execution time around joinPoint.proceed()
  • The #1 mistake: forgetting proceed() stops your method from running!
Keep going

More walkthroughs.