当需要在Spring Boot启动后搞点事情的时候,实现ApplicationRunner 或CommandLineRunner
@Component
public class MyBean implements CommandLineRunner {
public void run(String... args) {
// Do something...
}
}
ApplicationRunner提供ApplicationArguments作为参数,CommandLineRunner提供String[]
网友评论