spring配置文件里增加:
命令空间:
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
配置:
<task:annotation-driven/>
当然这还需要扫描注解等常规配置。
package com.test;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class TestJob {
@Scheduled(fixedDelay = 1000)
public void test()
{
System.out.println("job 开始执行");
}
}