title: AOP with Spring Boot Advice Not Triggering
body: <p>Using: Spring Boot :: (v1.2.8.RELEASE)</p>
  
  <p>I have set up a Spring Boot application with the aop starter in build.gradle</p>
  
  <pre><code>compile("org.springframework.boot:spring-boot-starter-aop")
  </code></pre>
  
  <p>I have checked and I am getting the dependencies:</p>
  
  <pre><code>|    |    |    |         +--- org.springframework:spring-aop:4.1.9.RELEASE
  |    |    |    |         |    +--- aopalliance:aopalliance:1.0
  </code></pre>
  
  <p>This is the AspectConfig:</p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAspectJAutoProxy
  public class AspectConfig {
      @Bean
      public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  }
  </code></pre>
  
  <p>I have placed the Configuration class at the base of the application hierarchy, so that the component scanning just covers the whole application. This is all prototype code,but it will eventually form part of a starter module, the the ability to scan all areas would be helpful.</p>
  
  <p>Now I have defined an annotation:</p>
  
  <pre><code>@Retention(RetentionPolicy.RUNTIME)
  @Target({ElementType.METHOD})
  public @interface AutowiredRestTemplate {
      String name();
      String methodUrl();
  }
  </code></pre>
  
  <p>And have a test method:</p>
  
  <pre><code>@Component(value = "testGateway")
  public class TestGatewayImpl implements TestGateway {
      private static final Logger LOG = LoggerFactory.getLogger(TestGatewayImpl.class);
  
      AuspostRestTemplate restTemplate;
  
      @AutowiredRestTemplate(name = "locations", methodUrl = "/fishing")
      public Response doWork() {
          LOG.debug("Got into gateway with restTemplate {}", restTemplate);
          return restTemplate.getForObject(Response.class);
      }
  }
  </code></pre>
  
  <p>and now the advice:</p>
  
  <pre><code>@Aspect
  @Component
  public class AutowiredRestTemplateAspect {
  
      @Autowired
      Map&lt;String, AuspostRestTemplate&gt; restTemplateMap;
  
      @Autowired
      private ApplicationContext context;
  
      @Pointcut("execution(public * *(..))")
      public void anyPublicMethod(){}
  
      @Around("anyPublicMethod() &amp;&amp; @annotation(autowiredRestTemplate)")
      public Object inAnyMethod(ProceedingJoinPoint pjp, AutowiredRestTemplate autowiredRestTemplate) throws Throwable{
  
          AuspostRestTemplate restTemplate = restTemplateMap.get(autowiredRestTemplate.name());
          restTemplate.setMethodUrl(autowiredRestTemplate.methodUrl());
              pjp.getTarget().getClass().getDeclaredField("restTemplate").set(pjp.getTarget(),restTemplate);
          return pjp.proceed();
  
      }
  }
  </code></pre>
  
  <p>The issue is that the Advice never gets triggered when the <code>doWork()</code> method is run. It even looks as though from the logs that the pointcut doesn't even get set up. Can anyone see what's wrong here?</p>
  
  <p><strong>EDIT:</strong> I have added the Config and the Retention and Target annotations for the Annotation that I want to use (above in this question).
  <strong>EDIT2:</strong> Changed the ComponentScan on the Configuration class as the other thing was complicated and didn't work anyway.</p>