/**
*
* 服务启动时,@ComponentScan扫描到@Component后,将FileDownloadRunner装入spring容器中时执行
* 任务
*
*/
@Component
public class FileDownloadRunner implements CommandLineRunner {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Override
public void run(String... args) throws Exception {
//根据情况选择是否新建线程
new Thread(() -> {
log.info("任务开始执行");
}).start();
}
}
springboot启动服务时执行任务
最新推荐文章于 2023-10-03 13:40:18 发布