来自:https://stackoverflow.com/questions/27378292/launch-browser-automatically-after-spring-boot-webapp-is-ready

import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException; public class Browser {
public static void main(String[] args) {
String url = "http://www.google.com"; if(Desktop.isDesktopSupported()){
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI(url));
} catch (IOException | URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("xdg-open " + url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

spring-boot启动后在浏览器打开指定页面的更多相关文章

  1. 微信如何实现自动跳转到用其他浏览器打开指定页面下载APP

    不管是app的下载链接还是普通文件的链接在微信内置浏览器或者QQ内置浏览器都会被屏蔽.这是微信对第三方下载域名实施的拦截政策.被拦截了用户在微信内打开就会提示“已停止访问该网页”. 那么当我们遇到这个 ...

  2. 在Spring Boot启动后执行指定代码

    在开发时有时候需要在整个应用开始运行时执行一些特定代码,比如初始化环境,准备测试数据等等. 在Spring中可以通过ApplicationListener来实现相关的功能,不过在配合Spring Bo ...

  3. idea中spring boot启动后无法访问jsp

    出自:https://www.jianshu.com/p/470b28d76147 第一种: 打开File > Project Structure > Facetes 如图1: 图1 如果 ...

  4. Spring boot启动后没有生成日志文件问题排错

    我的配置是: logging.file.name=spring-boot.log logging.file.path=D:/log/ 系统启动后日志文件没有生成 原因:一开始以为这两个属性是配合着使用 ...

  5. 问题之Spring MVC配置后,可以打开jsp页面,但打不开html页面

    一.配置Spring MVC 1.导入jar spring框架:http://repo.spring.io/release/org/springframework/spring/ spring-fra ...

  6. spring boot 启动后执行初始化方法

    http://blog.csdn.net/catoop/article/details/50501710 1.创建实现接口 CommandLineRunner 的类 package org.sprin ...

  7. spring boot启动后执行方法

    @Componentpublic class InitProject implements ApplicationRunner { private static final Logger logger ...

  8. Spring boot启动成功后输出提示

    添加logback-spring.xml,将log输出到文件,控制台输出的level改为error因此只会出处banner src/main/resources/banner.txt的内容为 star ...

  9. Spring Boot 启动(二) Environment 加载

    Spring Boot 启动(二) Environment 加载 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) 上一节中 ...

随机推荐

  1. Android R文件的id

    如果你用 apktoool 反编译过 apk 就知道,反编译后res/values 下有一个 public.xml 文件,内容如图     这个东西有什么用呢?   先从如何使用资源 ID 开始,在开 ...

  2. linux安装memcache及memcache扩展

    一.安装libevent# wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz# tar zxf libevent-2.0 ...

  3. 在Android模拟器里安装apk

    [原文]http://Android.tgbus.com/android/tutorial/201104/349532.shtml 1.运行SDK Manager,选择模拟器,并运行模拟器. 2.将需 ...

  4. MVC4 Action 两种异步方式

    1. xxxAsync/xxxCompleted 组合方式异步,xxxCompleted  就是他的回调函数,在执行完 xxxAsync 后调用xxxCompleted  . 使用 异步方式必须继承A ...

  5. 微软2014实习生招聘笔试第2题 the k-th string

    Time Limit: 10000msCase Time Limit: 1000msMemory Limit: 256MB Description Consider a string set that ...

  6. Web Server 在IIS上部署ASP.NET Core项目

    在IIS上部署ASP.NET Core项目 一.配置应用程序池为无托管: 二.安装ASPNETCoreModule:(核心) 下载地址:https://go.microsoft.com/fwlink/ ...

  7. Tomcat源码(一):整体架构

    由于tomcat的组件较多,处理流程比较复杂 ,这里是 由浅到深来解释tomcat的整体架构 1.首先应该大致了解下tomcat的 /conf/server.xml  配置文件:在tomcat启动的时 ...

  8. 2.ECMAScript 5.0

    JS的引入方式 内接式 <script type="text/javascript"> </script> 外接式 <!--相当于引入了某个模块--& ...

  9. dataframe 转为list

    首先使用np.array()函数把DataFrame转化为np.ndarray(),再利用tolist()函数把np.ndarray()转为list.

  10. Hadoop完全分布式搭建全过程

    本次操作共4台虚拟机(node211,node212,node213,node214),node211为NameNode,其余3台为DataNode,SecondaryNamenode为node212 ...