说明:
当有写代码需要在项目启动时执行的时候(即项目启动完成前),可以使用这个方法。
步骤:
代码:
import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; @Component public class RunTest implements CommandLineRunner { @Override public void run(String... args) throws Exception { System.err.println("hello beauty"); } }
代码截图示例:
原文:https://www.cnblogs.com/lu51211314/p/9564897.html