引入依赖
1 2 3 4 5
| <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.3.2</version> </dependency>
|
Java代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| package com.ledao.quartz; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; import java.util.*;
@Configuration @EnableScheduling public class DeleteInvalidImage { @Resource private BlogService blogService; @Scheduled(cron = "0 0 23 * * ?") public void work() { } }
|
PS.
常用cron表达式:常用 cron 表达式 | LeDao’s Blog (zoutl.cn)