方法太长的不要这样,因为这种方式是要等方法执行完才会启动项目
一,ApplicationRunner 接口
@Component
public class Runner implements ApplicationRunner {
@Autowired
private ZkUserService zkUserService;
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("===============");
}
}
二,CommandLineRunner 接口
@Component
public class Runner implements CommandLineRunner {
@Autowired
private ZkUserService zkUserService;
@Override
public void run(String... args) throws Exception {
System.out.println("===============");
}
}