Spring mvc 定时任务配置

1.xmlns:task="http://www.springframework.org/schema/task"

2. http://www.springframework.org/schema/task  
http://www.springframework.org/schema/task/spring-task.xsd

3.default-lazy-init="false"  会影响整个spring启动的速度,在对应的定时任务类上加上@Lazy(false)

4.<task:annotation-driven />

5.@Component

6.@Scheduled(cron='0/1 * * * * ?')

7.

package com..assetManage.task;


import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
@Lazy(false)
public class DealSchema {

@Scheduled(cron="${Scheduled}")
public void deal_tb(){
System.out.println("定时任务……");
}


}

猜你喜欢

转载自blog.csdn.net/hansplay/article/details/78918777
今日推荐