zoukankan      html  css  js  c++  java
  • springBoot启动加载笔记

    1.在启动类上增加注解@SpringBootApplication和在main方法里面调用SpringApplication的静态方法run

    我们开发任何一个Spring Boot项目,都会用到如下的启动类

    复制代码
    @SpringBootApplication
    public class Application {
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    复制代码

    从上面代码可以看出,Annotation定义(@SpringBootApplication)和类定义(SpringApplication.run)最为耀眼,所以要揭开SpringBoot的神秘面纱,我们要从这两位开始就可以了。

    2.在@SpringBootApplication注解源码可以看到包含了哪些注解,主要是三个SpringBootConfiguration,EnableAutoConfiguration, ComponentScan

    SpringBootApplication背后的秘密

    复制代码
    @Target(ElementType.TYPE)            // 注解的适用范围,其中TYPE用于描述类、接口(包括包注解类型)或enum声明
    @Retention(RetentionPolicy.RUNTIME)  // 注解的生命周期,保留到class文件中(三个生命周期)
    @Documented                          // 表明这个注解应该被javadoc记录
    @Inherited                           // 子类可以继承该注解
    @SpringBootConfiguration             // 继承了Configuration,表示当前是注解类
    @EnableAutoConfiguration             // 开启springboot的注解功能,springboot的四大神器之一,其借助@import的帮助
    @ComponentScan(excludeFilters = {    // 扫描路径设置(具体使用待确认)
            @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
            @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
    public @interface SpringBootApplication {
    ...
    }

    3.
  • 相关阅读:
    python学习之那些你不在乎却操作非主流的练习题(一)
    python学习之数据类型(int,bool,str)
    Python学习之格式化简述
    Python学习之认知(二)
    Python学习之认知(一)
    Python学习之初识
    scrollTo与scrollTop及其区别
    js点击当前元素传入id从而获取其他元素
    微信支付功能
    cookie,sessionStorage,localStorage区别
  • 原文地址:https://www.cnblogs.com/handsome1013/p/11078612.html
Copyright © 2011-2022 走看看