title: Is there any way to call @Scheduled annotation in main method in spring boot
body: <p>I just want to run my spring boot main method periodically by using @scheduler annotation. I have specified some additional code which will perform some pre-action before it enables REST services. </p>
  
  <pre><code>@EnableScheduling
  @SpringBootApplication
  public class SpringBootJDBCApp {
  
      @Autowired
      ITest testService;
  
      public static void main(String args[]) throws Exception  {
          PersistenceValidation.cloneGit();
          PersistenceValidation.dataPersistance();
          PersistenceValidation.cleanUp();
          ApplicationContext context = SpringApplication
                  .run(SpringBootJDBCApp.class);
          ITest testService = context.getBean(ITestService.class);
          testService.getAllData();
      }
  }
  </code></pre>
  
  <p>I want to run the above main method every 10seconds once. and Added @Schedule annotation at main method. But It throws an exception: </p>
  
  <blockquote>
    <p>Expected behavior as per doc @Scheduler should be called a method which doesn't have args[]</p>
  </blockquote>
  
  <p>I wanna use <code>@Scheduler</code> annotation in main method as below:</p>
  
  <pre><code>@Scheduled(initialDelay = 1000, fixedRate = 10000)
  public static void main(String args[]) throws Exception {
      PersistenceValidation.cloneGit();
      PersistenceValidation.dataPersistance();
      PersistenceValidation.cleanUp();
      ApplicationContext context = SpringApplication.run(SpringBootJDBCApp.class);
      ITest testService = context.getBean(ITestService.class);
      testService.getAllData();
  }
  </code></pre>
  
  <p><strong>Error</strong>:</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springBootJDBCApp': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Encountered invalid @Scheduled method 'main': Only no-arg methods may be annotated with @Scheduled</p>
  </blockquote>
  
  <p>Is there any other way to achieve this task? I wanna run the entire things which are mentioned in the main method periodically. </p>
  
  <p>Any leads?</p>