在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()));
}
}
本文介绍如何在Spring配置文件中启用定时任务支持,并展示了一个使用@Scheduled注解的简单示例。

3624

被折叠的 条评论
为什么被折叠?



