import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableScheduling;
//定时任务案例
@SpringBootApplication
@EnableScheduling//
@PropertySource(value={"file:I:/demo/testpzwj/config/application.properties"})//指定配置文件位置
public class SchedulingApplication {
public static void main(String[] args) {
SpringApplication.run(SchedulingApplication.class, args);
}
}
本文详细介绍如何在SpringBoot项目中使用@EnableScheduling注解开启定时任务,通过具体代码示例展示如何配置application.properties文件的位置,以便更好地理解和应用定时任务功能。

被折叠的 条评论
为什么被折叠?



