title: Spring AOP pointcut for custom annotation not working inner static class
body: <p>At the moment, I have the following Pointcut.</p>
  
  <pre><code>@Target({ ElementType.TYPE, ElementType.METHOD })
  @Retention(RetentionPolicy.RUNTIME)
  public @interface MyAnnotation {
      @Aspect
      @Component
      public static class MyAnnotationAspect {
          @Pointcut("execution(* (@com.test.MyAnnotation *).*(..))")
          public void methodInMyAnnotationType() {}
  
          @Around("methodInMyAnnotationType()")
          public Object annotate(ProceedingJoinPoint pjp) throws Throwable {
              System.out.println("AOP WORKING");
              return pjp.proceed();
          }
      }
  }
  </code></pre>
  
  <p>It's working fine when I add <code>@MyAnnotation</code> on root level classes as following.</p>
  
  <pre><code>@MyAnnotation
  @Service
  public class ShiftModule {
      @Resource
      private ShiftModule self;
  
      /* Executing anything using self.method() triggers the Aspect
       * for @MyAnnotation perfectly
       */
  }
  </code></pre>
  
  <p>It's also not working if I add the annotation on an inner static class.</p>
  
  <pre><code>@Service
  public class ShiftModule {
      @Service
      @MyAnnotation
      public class AnnotatedShiftModule extends ShiftModule {}
  
      @Resource
      private AnnotatedShiftModule self;
  
      /* Executing anything using self.method() does NOT trigger the 
       * Aspect for @MyAnnotation or even framework's annotations
       * like @Async
       */
  }
  </code></pre>
  
  <p>If I use this technique on an interface, it works.</p>
  
  <pre><code>@Repository
  public interface OrderRepo extends JpaRepository&lt;Order,Long&gt; {
      @Repository("annotatedOrderRepo")
      @MyAnnotation
      public interface AnnotatedOrderRepo extends OrderRepo {}
  }
  </code></pre>
  
  <p>I'd be very grateful if you could show me how to make it work with classes and Spring beans.</p>