zoukankan      html  css  js  c++  java
  • SpringBoot常用starter解读

     

    一,核心starter

    1,spring-boot-starter-parent 版本控制

    2,spring-boot-starter 核心启动器,依赖为,sprring-boot, spring-boot-autoconfig, spring-boot-starter-logging, spring-core, javax.annotation-api

    3,spring-boot-starter-web 支持全栈web开发,依赖为,spring-web, spring-webmvc, spring-boot-starter-tomcat

    4,spring-boot-starter-actuator 监控和管理应用

    5,spring-boot-starter-test  支持常规测试,依赖为: spring-core, spring-test, junit, spring-boot-test, spring-boot-test-autoconfig

     

    二,常用starter

    1,spring-boot-starter-jdbc

    2,spring-boot-starter-security

    3,spring-boot-starter-amqp 

    4,spring-boot-starter-data-redis 

    5,spring-boot-starter-data-elasticsearch

    6,spring-boot-starter-data-mongodb

    7,spring-boot-starter-thymeleaf 

    8,spring-boot-starter-freemarker

    9,spring-boot-starter-mail 

    10,spring-boot-starter-aop 

       附:所有starter

     

    三,解读 ServletWebServerFactoryAutoConfiguration

    Code: 

    3.1 先看下标记的注解:

     

    @Configuration 配置类注解

    @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) 自动配置顺序,最高优先级[同级的还有DispatcherServletAutoConfiguration。扩展下,还有次高级(WebMvcAutoConfiguration),无级别(HttpEncodingAutoConfiguration等),依赖链(属于无级别)]

    @ConditionalOnClass(ServletRequest.class) 条件类, 指定的ServletRequest类存在生效

    @ConditionalOnWebApplication(type = Type.SERVLET) 条件类,指定为Web应用下生效

    @EnableConfigurationProperties(ServerProperties.class) 启动ServerProperties类的属性值注入功能,将server的port, address等属性注入到IOC容器中

    @Import({ ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar.class,

     ServletWebServerFactoryConfiguration.EmbeddedTomcat.class,

     ServletWebServerFactoryConfiguration.EmbeddedJetty.class,

     ServletWebServerFactoryConfiguration.EmbeddedUndertow.class }) 导入注册Servlet服务配置类,用于返回指定的容器:Tomcat/Jetty/Undertow

     

     3.2 该自动配置类被执行顺序如下:

    1)init: BeanPostProcessorsRegistrar.setBeanFactory/.registerBeanDefinitions

    2)return: ServletWebServerFactoryCustomizer

     

    3.3  详细Debug看下加载过程为:

    a,

    b,

    c,

     

  • 相关阅读:
    bootstrap的引用和注意事项
    css样式表的知识点总结
    数据去重宏脚本
    redis总结
    list对象中根据两个参数过滤数据
    dt常用类
    C#删除字符串最后一个字符的几种方法
    C#的split分割的举例
    数据库优化的几个注意点
    两种转换城市的方式
  • 原文地址:https://www.cnblogs.com/Jashinck/p/15115536.html
Copyright © 2011-2022 走看看