spring项目启动后立即执行方法的四种办法
一、定时任务
1.启动类头加 @EnableScheduling
3.类头加 @EnableScheduling
4.方法加 @Scheduled(cron = “0 0 7 ? * ** *”) //每天早上7点触发
二、controller 的 postman调用
三、方法上加注解@PostConstruct(推荐)
四、重写afterPropertiesSet方法

程序启动执行顺序:
@PostConstruct > afterPropertiesSet() > initMethod()