TaskDemo.java 876 B

12345678910111213141516171819202122232425262728
  1. package com.ym.mec.collectfee.job;
  2. import org.springframework.context.annotation.Configuration;
  3. import org.springframework.scheduling.annotation.EnableScheduling;
  4. import org.springframework.scheduling.annotation.Scheduled;
  5. import org.springframework.stereotype.Component;
  6. import java.time.LocalDateTime;
  7. @Component
  8. @Configuration
  9. @EnableScheduling
  10. public class TaskDemo {
  11. /*@Scheduled(cron = "0/5 * * * * ?")
  12. //或直接指定时间间隔,例如:5秒
  13. //@Scheduled(fixedRate=5000)
  14. private void taskOne() {
  15. System.err.println("执行静态定时任务时间1111: " + LocalDateTime.now());
  16. }
  17. @Scheduled(cron = "0/5 * * * * ?")
  18. //或直接指定时间间隔,例如:5秒
  19. //@Scheduled(fixedRate=5000)
  20. private void taskTwo() {
  21. System.err.println("执行静态定时任务时间222: " + LocalDateTime.now());
  22. }*/
  23. }