Spring3 定时任务

来源:互联网 发布:知乎 雷洋 编辑:程序博客网 时间:2024/06/07 09:04
1、定时任务类和方法
@Componentpublic class TestTask {private static Logger LOG = LoggerFactory.getLogger(TestTask.class);@Scheduled(cron = "0 50 23 * * SUN")public void doTask(){try{LOG.info("doTask:{}", "执行任务...");}catch(Exception e){LOG.error("doTask:{}", e.toString());}}}
2、Spring xml配置要点
<context:component-scan base-package="com.demo" use-default-filters="false"><context:include-filter type="annotation" expression="org.springframework.stereotype.Component"/></context:component-scan>

<task:annotation-driven />


0 0
原创粉丝点击