//配置默认访问路径 并且自动打开浏览器  需要创建独立文件
@Controller
public class HomeController {
    @RequestMapping("/")
    public String toIndex() {// 配置默认访问首页
        return "redirect:/index.jsp";
    }

  //自动打开浏览器

    @EventListener({ApplicationReadyEvent.class})
    void applicationReadyEvent() {
        String url = "http://localhost:9999/index.jsp";
        Runtime runtime = Runtime.getRuntime();
        try {
            runtime.exec("rundll32 url.dll,FileProtocolHandler " + url);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
//配置默认启动页面第二种
@Configuration
public class HomeController extends WebMvcConfigurerAdapter {
    @Override
    public void addViewControllers( ViewControllerRegistry registry )
    {
        registry.addViewController( "/" ).setViewName( "redirect:/index.jsp" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
        super.addViewControllers( registry );
    }
}
//创建一个独立的文件  配置全局启动
@SpringBootApplication(scanBasePackages = {"cn.java.controller","cn.java.service.impl"})
@MapperScan(value = "cn.java.mapper")
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
}

Springboot 项目启动设置的更多相关文章

  1. Springboot项目启动不了。也不打印任何日志信息。

    Springboot项目启动不了.也不打印任何日志信息. <!-- 在创建Spring Boot工程时,我们引入了spring-boot-starter,其中包含了spring-boot-sta ...

  2. Springboot 项目启动后执行某些自定义代码

    Springboot 项目启动后执行某些自定义代码 Springboot给我们提供了两种"开机启动"某些方法的方式:ApplicationRunner和CommandLineRun ...

  3. springBoot项目启动类启动无法访问

    springBoot项目启动类启动无法访问. 网上也查了一些资料,我这里总结.下不来虚的,也不废话. 解决办法: 1.若是maven项目,则找到右边Maven Projects --->Plug ...

  4. SpringBoot项目启动时链接数据库很慢

    SpringBoot项目启动时链接数据库很慢 springboot项目在启动时候,如下图所示,链接数据库很慢 解决方法:在mysql 的配置文件中 配置 skip-name-resolve

  5. springboot项目启动成功后执行一段代码的两种方式

    springboot项目启动成功后执行一段代码的两种方式 实现ApplicationRunner接口 package com.lnjecit.lifecycle; import org.springf ...

  6. springboot项目启动之后初始化自定义配置类

    前言 今天在写项目的时候,需要再springboot项目启动之后,加载我自定义的配置类的一些方法,百度了之后特此记录下. 正文 方法有两种: 1. 创建自定义类实现 CommandLineRunner ...

  7. 【log4j】springboot项目启动 ,使用的druid数据源,log4j报错 log4j:WARN Please initialize the log4j system properly.

    springboot项目启动 ,使用的druid数据源,log4j报错 -- :: --- [ restartedMain] o.hibernate.annotations.common.Versio ...

  8. springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde

    springboot项目启动报错Failed to configure a DataSource: 'url' attribute is not specified and no embedde 创建 ...

  9. springboot项目启动无法访问到controller原因之一:引导类位置有问题

    新建的springboot项目启动后,无法访问到controller 页面是404错误 查看项目结构,发现是新建工程的启动类位置有问题,controller类应该位于引导类的同级包或者子级包中.需要将 ...

随机推荐

  1. leetCode练题——38. Count and Say

    1.题目 38. Count and Say The count-and-say sequence is the sequence of integers with the first five te ...

  2. laravel npm安装yarn

    npm install -g yarn yarn install --no-bin-links yarn add cross-env npm run dev Laravel 默认集成了一些 NPM 扩 ...

  3. DotNet中静态成员、静态类、静态构造方法和实例构造方法的区别与联系

    在面向对象的C#程序设计中,关于静态的概念一直是很多人搞不明白的.下面介绍这些带“静态”的名称. 1.静态成员: 定义:静态成员是用static关键字修饰的成员(包括字段属性和方法) 所属:静态成员是 ...

  4. Python中注释与声明

    Python中注释的写法 #:使用井号进行单行注释 Python中貌似没有提供多行注释,不过我们可以利用三引号的多行字符串来进行多行注释 """ 多行注释内容 多行注释内 ...

  5. DDL与DML的区别

    DML(Data Manipulation Language)数据操纵语言: 适用范围:对数据库中的数据进行一些简单操作,如insert,delete,update,select等. DDL(Data ...

  6. C - Water The Garden

    It is winter now, and Max decided it's about time he watered the garden. The garden can be represent ...

  7. 整个DIV 块垂直居中

    <!-- 垂直居中一定要有确定大小的 父容器(根) html,body 一般100% --> <!DOCTYPE html> <html lang="en&qu ...

  8. 安装oracle11g时出现:在注册表中没有找到指定的主目录名

    我碰到这个问题,不过我没去管它.直接安装了,后来数据库实例,什么的都能安装,目前没有发现什么问题. 造成这个的原因:是卸载oracle时注册表没有彻底删除! 如果后面出现问题,再记录.

  9. Day11 - B - Dice (III) LightOJ - 1248

    设dp_i为已经出现了i面,需要的期望次数,dp_n=0 那么dp_i= i/n*dp_i + (n-i)/n*dp_(i+1) + 1 现在已经i面了,i/n的概率再选择一次i面,(n-i)/n的概 ...

  10. 并发编程之第三篇(synchronized)

    并发编程之第三篇(synchronized) 3. 自旋优化 4. 偏向锁 撤销-其它线程使用对象 撤销-调用wait/notify 批量重偏向 批量撤销 5. 锁消除 4.7 wait/notify ...