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 }
     
  • 相关阅读:
    【leetcode】1. Two Sum
    【leetcode】32. Longest Valid Parentheses
    【leetcode】20. Valid Parentheses
    scala细节
    【转】CentOS下firefox安装flash说明
    Spring 容器(一)
    源码学习快捷键
    Gradle编译spring3.x报错找不到itextpdf4.2.2解决方案
    Insertion Sort
    Bubble Sort
  • 原文地址:https://www.cnblogs.com/wxy0715/p/12376932.html
Copyright © 2011-2022 走看看