title: Why does Spring @Scheduled not work with @Bean
body: <p>I am using Spring Boot and Scheduling.</p>
  
  <p>In Spring, why does this work properly (the method gets called every 5 seconds) -</p>
  
  <pre><code>//@Bean
  @Scheduled(fixedRate = 5000)
  public void foo() {
       System.out.println("bar");
  }
  </code></pre>
  
  <p>But this does not (the method does not get called every 5 seconds) -</p>
  
  <pre><code>@Bean
  @Scheduled(fixedRate = 5000)
  public void foo() {
       System.out.println("bar");
  }
  </code></pre>