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 https://www.word.com:22599/dist/index.html");//指定自己項目的路徑 } catch (Exception ex) { ex.printStackTrace(); } } }
寫個controller直接丟進去