@Component
public class ApplicationInitListener implements ApplicationListener<ContextRefreshedEvent> {
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
System.out.println("ContextRefreshedEvent.....容器初始化完成");
}
}
@Component
public class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
@Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
System.out.println("ApplicationReadyEvent.....");
}
}
import java.util.Arrays;
/**
* @Author: ldj
* @Date: 2023/06/21/16:59
* @Description:
*/
@Order(-1)
@Component
public class Test3Runner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("Test3Runner执行一次....." + Arrays.toString(args.getSourceArgs()));
}
}
@Order(1)
@Component
public class TestOneRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("TestOneRunner执行一次.....");
}
}
@Order(0)
@Component
public class TestTowRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("TestTowRunner执行一次.....");
}
}