CommandLineRunner
接口,重写run()
方法即可@Component
public class OpenBrowser implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("开始自动加载指定的页面");
try {
Runtime.getRuntime().exec("cmd /c start http://localhost:8080/boot01");//可以指定自己的路径
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
原文:https://www.cnblogs.com/shmebluk/p/13859647.html