springboot 启动后打开应用首页
在启动类中添加监听时间
@EventListener({ApplicationReadyEvent.class})
public void applicationReadyEvent() {
System.out.println("应用已经准备就绪,正在启动浏览器");
String url = "http://localhost:7000";
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
} catch (IOException e) {
e.printStackTrace();
}
}
//服务器终止监听
@EventListener({ContextClosedEvent.class})
public void applicationExitEvent() {
System.out.println("应用终止");
}