Skip to content

task-joy是仿写Spring的Task模块,简化Spring一些复杂步骤,使用注解@EnableScheduling2和@Scheduled2来定时任务。🔥

Notifications You must be signed in to change notification settings

butterflyzh/task-joy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

task-joy

task-joy是仿写Spring的Task模块,简化Spring一些复杂步骤,使用注解@EnableScheduling2和@Scheduled2来定时任务。

效果

编写启动类,使用@EnableScheduling2 注解

@SpringBootApplication
@EnableScheduling2
public class TaskJoyApplication {

    public static void main(String[] args) {
        SpringApplication.run(TaskJoyApplication.class, args);
    }

}

使用@Scheduled2注解创建一个任务

@Component
public class MyTask {

    @Scheduled2(value = "task1", cron = "*/5 * * * * ?")
    public void task() {
        System.out.println("执行了");
    }
}
运行

About

task-joy是仿写Spring的Task模块,简化Spring一些复杂步骤,使用注解@EnableScheduling2和@Scheduled2来定时任务。🔥

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published