
来源:http://blog.csdn.net/weixin_42949841/article/details/108695570

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
</parent>
<dependencies>
<!-- SpringBoot 核心组件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
@EnableScheduling
@MapperScan("com.less.parent.dao")
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
@Component
public class SchedulingTask {
//表示每隔3秒
// @Scheduled(fixedRate = 3000)
// 表示方法执行完成后5秒
// @Scheduled(fixedDelay = 5000)
// 表示每五秒执行一次
@Scheduled(cron = "*/5 * * * * ?")
public void TestTask() {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(new Date()));
}
}
2020-09-20 17:20:35
2020-09-20 17:20:40
2020-09-20 17:20:45
-END-
SSM框架权限系统脚手架教程(资料全)加我微信回复“SSM框架权限”即可获取点个在看!?谢谢支持哟 (*^__^*)