天天看点

Springboot项目启动后自动在浏览器打开

Springboot项目启动后自动在浏览器打开
try {
      InetAddress addr = InetAddress.getLocalHost();
      System.out.println("Local HostAddress: "+addr.getHostAddress());
      Runtime.getRuntime().exec("cmd   /c   start   http://"+addr.getHostAddress()+":8080/files");//可以指定自己的路径
    } catch (Exception ex) {
      ex.printStackTrace();
    }