-  
概述:(Spring Boot是干什么的?)
 
       1. 简化Spring搭建使用过程的;也就是官网中的"just run" 只是运行;
        2. 使用一种最简单的方式(最少的麻烦)搭建Spring平台 整合第三方库;
        3.大部分的Spring应用使用最少的配置configuation。
-  
特点:
 
- 创建单独的Spring应用;
 - 内嵌tomcat jetty undertow容器(不需要自己再手动配置tomcat了,不需要部署WAR包);
 - 提供一个独特的starter依赖简化配置(pom文件的简化);
 - 尽可能的自动配置spring和第三方jar包(自动装配);
 - 绝对没有代码生成,不需要xml(页面干净)
 
-  
运行原理:
 
在我们创建SpringBoot项目后,会生成一个SpringbootMybatisApplication类,也就是我们项目的启动类。
@SpringBootApplication //该注解为复合注解
@MapperScan("com.wyb.sbm.dao") //mapper扫描 只扫描到dao
public class SpringbootMybatisApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringbootMybatisApplication.class, args);
    }
} 
在启动类中的@SpringBootApplication注解是SpringBoot的重点,该注解为一个复合注解,该注解包含以下几个注解
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan 
- 这四个注解为元注解 修饰其他注解的注解
 
    @Target({ElementType.TYPE})
         定义该注解使用的位置 参数ElementType.TYPE说明只能使用类,接口以及枚举上
     @Retention(RetentionPolicy.RUNTIME)
         定义该注解的保存策略 参数RetentionPolicy.RUNTIME说明在运行时使用
     @Documented
         导出生成文案后显示该注解
     @Inherited
         该注解可以被子类继承
- 这三个为核心注解
 
    @SpringBootConfiguration
         本质为 @Configuration 相当于过去的xml文件中的beans
     @EnableAutoConfiguration  
       (自动装配 resources下的META-INF中的spring.factories配置文件中的配置)
         本质为 @import 注解 配置接口ImportSelector的实现类AutoConfigurationImport  重写selectImports()方法 将list集合转化为Spring数组 该数组中的所有的类都会交给ioc容器管理
         自动装配 自动装载本项目或者第三方jar包中resources下meta-info/spring.factories文件中配置的类 或者是所有第三方jar包 该路径的文件中配置的类
     @ComponentScan
         组件扫描 扫包 相当于 ssm中的context:component-scanbase-package
         参数意义:将当前目录以及子孙目录中有Spring标识注解的类(@Controller @RestController @Service等等)交给IOC容器管理
- 启动类中的run方法:
 
    1,初始化启动上下文 ,声明并创建IOC容器,最终会返回IOC容器 ,刷新 IOC 容器,会调用 Spring 经典的 refresh() 来进行刷新,会进行所有的非懒加载的单实例 Bean 的注册,即创建容器中的所有组件(springboot特有的增加内嵌容器,也会在容器刷新中初始化)
     2,获取所有的运行监听器 ,并调用所有监听器的starting方法
     3,调用所有的 Runners,容器中按照类型获取 ApplicationRunner 、CommandLineRunner  这两种组件,并把它们放入一个集合中,并且调用AnnotationAwareOrderComparator.sort(runners) 对集合进行排序,相当于按照 @Order 注解进  行排序,顺序靠前的被排在前面,然后遍历所有的 Runner ,调用 run()










