定时任务采用注解的模式使用
1、增加开启定时任务配置
package com.ecej.meterread.task.base.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@EnableScheduling
public class SchedulConfig {
}
2、编写定时任务业务
package com.ecej.meterread.task.base.run;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@Service
public class Test {
@Scheduled(fixedRate = 50000)
public void testSchedul() {
System.out.println("Test Schedul ...");
}
}
关注公众号,将获得最新文章推送

网友评论