快速查看SpringBoot项目中的所有自启动执行方法
在SpringBoot项目本地调试过程中,若有不需要的自启动方法,则会捣乱输出大堆日志、修改数据等。以下是总结的SpringBoot项目的常见自定动方式:
@Scheduled(fixedRate = 5 * 60 * 100)定时的cron时间特别短- 继承
CommandLineRunner或ApplicationRunner的类的run方法 - 被
@EventListener注解的方法参数是ApplicationReadyEvent implements ApplicationListener<ContextRefreshedEvent>的类的onApplicationEvent(ContextRefreshedEvent event)@PostConstruct类初始化后执行操作,但是不能保证Spring容器已完全初始化,ApplicationContextAware不保证能取到值,最好用ApplicationRunner或者@EventListenerwhile(true)空构造器里的持续执行- 搜索
Quartz,JobDetailFactoryBean,CronTriggerFactoryBean,SimpleTriggerFactoryBean,SchedulerFactoryBean
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 byu_rself!
评论
