zoukankan      html  css  js  c++  java
  • Springboot 项目启动设置

    //配置默认访问路径 并且自动打开浏览器  需要创建独立文件
     1 @Controller
     2 public class 3     @RequestMapping("/")
     4     public String toIndex() {// 配置默认访问首页
     5         return "redirect:/index.jsp";
     6     }
     7   //自动打开浏览器
     8     @EventListener({ApplicationReadyEvent.class})
     9     void applicationReadyEvent() {
    10         String url = "http://localhost:9999/index.jsp";
    11         Runtime runtime = Runtime.getRuntime();
    12         try {
    13             runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
    14         } catch (IOException e) {
    15             e.printStackTrace();
    16         }
    17     }
    18 }
    //配置默认启动页面第二种
     1 @Configuration
     2 public class HomeController extends WebMvcConfigurerAdapter {
     3     @Override
     4     public void addViewControllers( ViewControllerRegistry registry )
     5     {
     6         registry.addViewController( "/" ).setViewName( "redirect:/index.jsp" );
     7         registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
     8         super.addViewControllers( registry );
     9     }
    10 }
    11 //创建一个独立的文件  配置全局启动
    12 @SpringBootApplication(scanBasePackages = {"cn.java.controller","cn.java.service.impl"})
    13 @MapperScan(value = "cn.java.mapper")
    14 public class Application {
    15     public static void main(String[] args) {
    16         SpringApplication.run(Application.class,args);
    17     }
    18 }
     
  • 相关阅读:
    Python内置函数(67)——zip
    Python内置函数(66)——vars
    Python内置函数(65)——type
    Python内置函数(64)——tuple
    Python内置函数(63)——super
    Python内置函数(62)——sum
    Python内置函数(61)——str
    Python内置函数(60)——staticmethod
    Hadoop初体验(续)--YARN
    Hadoop初体验
  • 原文地址:https://www.cnblogs.com/wxy0715/p/12376932.html
Copyright © 2011-2022 走看看