在Springboot项目的启动类里面添加
package com.itheima;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Springboot04SsmApplication {
public static void main(String[] args) {
SpringApplication.run(Springboot04SsmApplication.class, args);
// TODO 启动打开默认浏览器访问(添加以下代码)
try {
Runtime.getRuntime().exec("cmd /c start http://localhost:8080/pages/books.html");
} catch (Exception e) {
e.printStackTrace();
}
}
}