springBoot項目啟動后自動跳轉指定頁面


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直接丟進去


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM