import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@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://127.0.0.1:9099/index.html");//指定自己项目的路径
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
不是对每个项目都有作用。还有一种方法 回头再来补充~