网站建设开票税率视频号的链接在哪
ApplicationRunner 用于在 Spring 程序初始化后去做一些事情。在 Spring 容器初始化成功后,会调用 ApplicationRunner 的 run()
方法。
比如下面的程序,在程序启动后打印 “Hello”:
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;@Component
public class PreHelloApplicationRunner implements ApplicationRunner {@Overridepublic void run(ApplicationArguments args) throws Exception {System.out.println("Hello");}
}