spring-boot依赖分析

spring-boot依赖

spring-boot-starter-parent

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

此依赖用于管理项目资源过滤以及项目中的所有插件(这一步很明显是把web完全组织为一个application)

配置资源过滤以及插件管理

<build>
    <!--配置文件资源.ymal .yml .properties-->
    <resources>
    </resources>
    
    <!--插件-->
    <pluginManagement>
    </pluginManagement>
</build>

spring-boot-dependencies

spring-boot-dependencies是spring-boot-starter-parent 的父依赖

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.3.3.RELEASE</version>
  </parent>

存放该springboot项目中所有依赖以及依赖的版本

<!--版本号-->
<properties>
</properties>

<!--项目依赖-->
<dependencyManagement>
  <dependencies>
     <dependency>
       <version>${activemq.version}</version>
    </dependency>
  </dependencies>
<dependencyManagement>

在这里插入图片描述


spring-boot应用主程序类

@SpringBootApplication
public class SpringbootApplication {
   public static void main(String[] args) {
      SpringApplication.run(SpringbootApplication.class, args);
   }
}

@SpringbootApplication注解分解

@SpringbootApplication  SpringBoot应用
     @ComponentScan  自动扫描注册bean
     @SpringBootConfiguration   SpringBoot配置类
          @Configuration   Spring配置类
          @Component  Spring组件(该启动类是Spring中的一个组件,负责启动应用)
     @EnableAutoConfiguration   自动配置功能
         @AutoConfigurationPackage 自动配置包
              @Import({Registrar.class})  将主启动类的所在包及子包中的组件扫描到Spring容器 
         @Import({AutoConfigurationImportSelector.class}) 导入自动配置导入选择器

AutoConfigurationImportSelector

查询到Springboot的预设的自动配置类

    //获得预设配置
    protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {
        List<String> configurations = SpringFactoriesLoader.loadFactoryNames(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader());
        Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.");
        return configurations;
    }

spring.factories

在这里插入图片描述
存在于spring-boot-autoconfigure包中
spring.factories中存放着所有springboot自动使用JavaConfig类方式实现的spring组件,比如数据源、缓存机制、数据库驱动等,点进去可以看到具体的配置情况。
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值