java Springscheduling,调度程序仅在第一天晚上11:57运行,而不是在SpringMVC中每天运行
在我这里的mvc项目中,我想每天重复一个调度器,但它只在设备启动的第一天工作,而不是在设备永久启动的每一天
如果我重新启动我的设备,那么它也可以工作,但只能再工作一次
调度程序类所在的位置
@Configuration
@EnableScheduling
public class Sched {
@Scheduled(cron = "0 57 23 * * ?", zone="Asia/Kolkata")
public void schedulerCreateFolder(){
System.out.println("Hello Scheduller");
}
}
下面是web应用程序初始值设定项
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{
@Override
protected Class<?>[] getRootConfigClasses(){
return new Class[]{WebSecurityConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses(){
return new Class[]{WebAppConfig.class, HibernateConfiguration.class, Sched.class};
}
@Override
protected String[] getServletMappings(){
return new String[]{"/"};
}
}
我怎样才能修好它
# 1 楼答案
使用下面的代码在每天晚上11:57运行调度程序,您需要删除
zone
请检查此链接,您可以验证@Scheduled语法 https://www.freeformatter.com/cron-expression-generator-quartz.html