I recently tried to get this to work on my own, I know it has been a while since this question was asked, but my working (and very simple / simple) solution is shown below. This is the starting point for those who want this to work, refactoring as required in your application!
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import java.awt.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); openHomePage(); } private static void openHomePage() { try { URI homepage = new URI("http://localhost:8080/"); Desktop.getDesktop().browse(homepage); } catch (URISyntaxException | IOException e) { e.printStackTrace(); } } }
source share