- 实现CommandLineRunner接口,重写run方法即可
import org.springframework.boot.CommandLineRunner;import org.springframework.stereotype.Component;@Componentpublic class TestRunner implements CommandLineRunner { @Override public void run(String... strings) throws Exception { doSomething...... }}