Spring3 定时任务

1、定时任务类和方法
@Component
public 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 />


你可能感兴趣的:(Spring3 定时任务)