![]()
package com.tang.demo.util;import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringBootConfiguration; /** * 启动项目自动跳转到登陆页面 */ @SpringBootConfiguration public class AutoStartProjectInDefaultBrowser implements CommandLineRunner { @Override public void run(String ... args) throws Exception { try { Runtime.getRuntime().exec("cmd /c start http://localhost:8080/login"); } catch (Exception ex) { ex.printStackTrace(); } } }
本文介绍了一种在Spring Boot应用中实现项目启动后自动在默认浏览器打开登录页面的方法。通过实现CommandLineRunner接口并在run方法中调用Runtime.getRuntime().exec()执行特定命令来达到目的。
2187

被折叠的 条评论
为什么被折叠?



