package cn.boxku;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableAsync
@EnableScheduling
public class AsynchronousApplication {
public static void main(String[] args) {
SpringApplication.run(AsynchronousApplication.class, args);
}
}
package cn.boxku.service;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class ScheduledService {
@Scheduled(cron = "0/5 0/1 17 * * ?")
public void hello()
{
System.out.println(new Date());
System.out.println("你被執行了");
}
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結