SSM框架中配置定时任务

匿名 (未验证) 提交于 2019-12-03 00:22:01


在xmlns中添加

xmlns:task="http://www.springframework.org/schema/task"


在xsi中添加

http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd

在中间添加

<!-- 设置定时任务 --> <task:annotation-driven/>

@Scheduled(cron = "0 0 0 * * ?") //每天晚上12点执行

public void gettime() {

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

System.out.println("current time"+format.parse(new Date() ));

}












“0 15 10 ? * MON-FRI” 每个周一、周二、周三、周四、周五的10:15触发


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!