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