Spring自带的定时器

1:application.xml加上

<task:annotation-driven scheduler="qbScheduler" mode="proxy" />
<task:scheduler id="qbScheduler" pool-size="10"/>

2:定时器类加上注解

@Component
public class TaskJob {

3:定时器方法头上加上

// 每五秒执行一次
@Scheduled(cron = "0/5 * * * * ?")
public void TaskJob2() {

猜你喜欢

转载自www.cnblogs.com/wuqing23/p/9267092.html