首页 > 技术文章 > springBoot项目启动后自动跳转指定页面

pijunqi 2021-01-05 14:45 原文

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直接丢进去

今日是2022年5月14号 因妈妈恶性脑瘤复发急需用钱 不得已在此发布水滴筹链接 恳请好心人帮忙转发救救我妈妈 
 

推荐阅读