Reputation: 493
I have written one scheduler which is working as expected only with xml file. But I am unable to run this with Javaconfig class. Following is the code.
Scheduler:
public class DemoServiceBasicUsageCron {
@Scheduled(cron="*/5 * * * * ?")
public void demoServiceMethod()
{
System.out.println("Method executed at every 5 seconds. Current time is :: "+ new Date());
}}
Java config:
@Configuration
public class TestCron {
@Bean
public DemoServiceBasicUsageCron demoCron() {
System.out.println(" bean created ");
return new DemoServiceBasicUsageCron();
}}
I am reading the configuration file as
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestCron.class);
}
Needed any suggestions which it can work.
Regards Sai
Upvotes: 0
Views: 142