spring scheduled定时任务

来源:互联网 发布:淘宝双肩包店推荐 编辑:程序博客网 时间:2024/05/24 05:55

在spring配置文件中添加

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

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


<task:annotation-driven/>

如图:


代码实现:

@Component@Lazy(value = false)public class Test {    @Scheduled(cron = "*/5 * * * * ?")  public void test(){    System.out.println("task start !" + DateUtil.toString(new Date()));  }}


0 0
原创粉丝点击