0
我寫了一個調度程序,它只按照預期的方式使用xml文件。但是我無法用Javaconfig類來運行它。以下是代碼。@Scheduled與Javaconfig不兼容
調度:
public class DemoServiceBasicUsageCron {
@Scheduled(cron="*/5 * * * * ?")
public void demoServiceMethod()
{
System.out.println("Method executed at every 5 seconds. Current time is :: "+ new Date());
}}
Java的配置:
@Configuration
public class TestCron {
@Bean
public DemoServiceBasicUsageCron demoCron() {
System.out.println(" bean created ");
return new DemoServiceBasicUsageCron();
}}
我讀取配置文件作爲
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestCron.class);
}
需要哪些它可以工作的任何建議。
問候 西
Thanks @abaghel。它工作正常。 – abc