How to run spring scheduled task using executable jar
<p>I want to develop a stand alone application which will perform some task on schedule. I am using spring @scheduled and taskscheduler to achieve this. I can't use spring boot as it needs spring 4.* and my maven project has dependencies on other projects that use spring 3. 
Here is my code (<a href="http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/EnableScheduling.html" rel="nofollow">reference</a>):</p>

<p>Pom.xml :</p>

<pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;parent&gt;
    &lt;groupId&gt;com.pdp.ci&lt;/groupId&gt;
    &lt;artifactId&gt;ci&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;/parent&gt;
&lt;artifactId&gt;file-requester&lt;/artifactId&gt;
&lt;name&gt;file-requester&lt;/name&gt;
&lt;packaging&gt;jar&lt;/packaging&gt;

&lt;properties&gt;
    &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;java.version&gt;1.7&lt;/java.version&gt;
&lt;/properties&gt;

&lt;dependencies&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;com.pdp.ci&lt;/groupId&gt;
        &lt;artifactId&gt;common-requester&lt;/artifactId&gt;
        &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
        &lt;exclusions&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
                &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
            &lt;/exclusion&gt;
            &lt;exclusion&gt;
                &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
                &lt;artifactId&gt;httpcore&lt;/artifactId&gt;
            &lt;/exclusion&gt;
        &lt;/exclusions&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
        &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
        &lt;version&gt;4.4&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
        &lt;artifactId&gt;httpcore&lt;/artifactId&gt;
        &lt;version&gt;4.4.4&lt;/version&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;

&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
  &lt;!-- Build an executable JAR --&gt;
  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
  &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
  &lt;version&gt;3.0.2&lt;/version&gt;
  &lt;configuration&gt;
  &lt;/configuration&gt;
&lt;/plugin&gt;

&lt;plugin&gt; 
&lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; 
&lt;executions&gt; 
  &lt;execution&gt; 
    &lt;phase&gt;install&lt;/phase&gt; 
      &lt;goals&gt; 
        &lt;goal&gt;copy-dependencies&lt;/goal&gt; 
      &lt;/goals&gt; 
      &lt;configuration&gt; 
         &lt;outputDirectory&gt;${project.build.directory}/lib&lt;/outputDirectory&gt; 
      &lt;/configuration&gt; 
    &lt;/execution&gt; 
  &lt;/executions&gt; 
&lt;/plugin&gt; 
&lt;/plugins&gt;
&lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>Component class containing scheduled method:</p>

<pre><code>package com.ci.ias;

@Component
public class CustomRequester{

    @Scheduled(fixedRate=2000)
    public void processFiles(){
        logger.info("Process started");
        //task logic
    }
}
</code></pre>

<p>Configuration class:</p>

<pre><code>@Configuration
@EnableScheduling
@ComponentScan(basePackages="com.ci.ias")
public class Requester implements SchedulingConfigurer {

    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setScheduler(taskExecutor());
    }

    @Bean(destroyMethod="shutdown")
    public Executor taskExecutor() {
        return Executors.newScheduledThreadPool(100);
    }

}
</code></pre>

<p>I am able to build a jar. But unable to run as there is no 'main' method. How to run this scheduler using command line? I am a novice to this. Can anybody explain how does this work?</p>

<p>Thanks.</p>