CommandLineRunner、ApplicationRunner 接口是在容器启动成功后的最后一步回调
CommandLineRunner 可以用@Order(1)指定执行顺序
@Component
@Slf4j
public class TestRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
try{
test();
}catch (Exception e){
log.error("出错啦");
}
}
@Scheduled(cron = "0 0/1 * * * ?")
public void test(){
log.info("就想打个字"+(new Date()).toString());
}
}