Launch browser automatically after spring-boot webapp is ready

后端 未结 6 886
失恋的感觉
失恋的感觉 2020-12-15 09:43

How do I launch a browser automatically after starting the spring boot application.Is there any listener method callback to check if the webapp has been deployed and is read

6条回答
  •  隐瞒了意图╮
    2020-12-15 10:25

    @SpringBootApplication
    @ComponentScan(basePackageClasses = com.io.controller.HelloController.class)
    public class HectorApplication {
    
        public static void main(String[] args) throws IOException {
           SpringApplication.run(HectorApplication.class, args);
           openHomePage();
        }
    
        private static void openHomePage() throws IOException {
           Runtime rt = Runtime.getRuntime();
           rt.exec("rundll32 url.dll,FileProtocolHandler " + "http://localhost:8080");
        }
    }
    

提交回复
热议问题