SpringBoot自动装配、启动流程及自定义starter

基于STM32F1XX 、HAL库的LTR-303ALS-01 环境光传感器驱动应用C语言程序设计 printf("制造商ID: 0x%02X\r\n", LTR303_ReadManufacID());printf("器件ID: 0x%02X\r\n", LTR303_ReadPartID());LTR-303ALS-01是一款数字环境光传感器(ALS),由Lite-On公司生产。printf("LTR-303ALS初始化失败!printf("LTR-303ALS初始化成功!printf("数据无效\r\n");* @param mode: 0-待机, 1-激活。 阅读详情

作为一名Java程序员,Spring框架是我们平常工作中非常重要的一个框架。其为我们提供了IOC容器和AOP的功能,在很大程度上简化了我们项目中的开发,但随着我们使用Spring接入的组件的增加,相应的配置文件也越来越多,这些配置文件的维护也成为了一个比较繁琐的工作,这也是很多开发人员比较诟病的地方。

SpringBoot的出现便很好的解决了这个问题,在SpringBoot项目中我们不再关注那么多的配置文件,其提供的自动装配功能使我们能够更容易的用其来快速的搭建我们的应用。

在今天的文章中我们就介绍下SpringBoot的自动装配、应用的启动流程,并在最后介绍下如何自定义一个starter。

1、示例代码

在介绍之前,我们先通过示例代码看看如何使用SpringBoot搭建一个web应用,示例代码使用的是SpringBoot的最新版本3.0.0,该版本依赖JDK17,如果本地使用的JDK8请使用低版本的SpringBoot或者升级JDK。

创建spring-boot-sample的maven项目并添加相关依赖,其pom文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xh</groupId>
    <artifactId>spring-boot-sample</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

</project>

在创建好的项目中编写一个启动类,其内容如下:

package com.xh.sample.spring.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: Create by IntelliJ IDEA
 * @author: xh
 * @createTime: 2022/12/3 18:31
 */
@RestController
@SpringBootApplication
public class SpringBootSampleApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootSampleApplication.class, args);
    }

    @RequestMapping(value = "/hello")
    public String hello() {
        return "Hello World!!!";
    }
}

至此我们的示例代码就编写完成了,我们直接执行启动类中的main方法,启动完成后可以访问http://localhost:8080/hello进行测试。

我们在pom中引入了spring-boot-starter-web的依赖,便集成好了SpringMVC的功能,是不是很简单方便呢,这便是自动装配的魔力。

启动类中只需要添加@SpringBootApplication注解并调用SpringApplication.run方法即可,在下面的内容中我们主要就是围绕着这两点来进行介绍。

2、自动装配

自动装配是SpringBoot的核心,是基于Spring的注解及SPI机制进行的实现。当SpringBoot启动时会加载各个依赖包中META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports文件(我们使用的是SpringBoot3.0.0版本,之前的版本中需要自动装配的类也是定义在spring.factories中的),并将该文件中配置的类加载到Spring容器中。

开启自动装配的逻辑关键在@SpringBootApplication这个注解上,这个注解的源码如下:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
    @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
  // 需要排除的类
  @AliasFor(annotation = EnableAutoConfiguration.class)
  Class<?>[] exclude() default {};

  @AliasFor(annotation = EnableAutoConfiguration.class)
  String[] excludeName() default {};
  // 扫描的包  默认是当前包路径
  @AliasFor(annotation = ComponentScan.class, attribute = "basePackages")
  String[] scanBasePackages() default {};

  @AliasFor(annotation = ComponentScan.class, attribute = "basePackageClasses")
  Class<?>[] scanBasePackageClasses() default {};

  @AliasFor(annotation = ComponentScan.class, attribute = "nameGenerator")
  Class<? extends BeanNameGenerator> nameGenerator() default BeanNameGenerator.class;

  @AliasFor(annotation = Configuration.class)
  boolean proxyBeanMethods() default true;

}

从这段源码中我们可以看到@SpringBootApplication是一个复合注解;

  • @SpringBootConfiguration @Configuration的派生注解
  • @EnableAutoConfiguration 启用SpringBoot的自动装配
  • @ComponentScan Spring中的注意,用于扫描相应的包下被@Component及其派生注解修饰的类

因此,我们完全可以将这个注解替换为@Configuration、@EnableAutoConfiguration及@ComponentScan三个注解。

这里我们单独看下@EnableAutoConfiguration注解,其源码如下:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {

  String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration";

  Class<?>[] exclude() default {};

  String[] excludeName() default {};

}

在这个注解中的@AutoConfigurationPackage注解的作用是将启动类所在包下的所有组件注册到Spring容器中,跟踪源码会发现其会调用到BeanDefinitionRegistry.register方法,这个是Spring中相关的类,我们这里就不展开了。

@Import注解中跟着的类,在Spring容器启动时会进行加载,这里面设置的是AutoConfigurationImportSelector,这个类的作用是加载自动装配类,这个类实现了DeferredimportSelector接口并实现了selectImports方法,这个方法的作用是收集所有需要加载到Spring容器中的类名。其逻辑如下:

public String[] selectImports(AnnotationMetadata annotationMetadata) {
  if (!isEnabled(annotationMetadata)) {
    return NO_IMPORTS;
  }
  AutoConfigurationEntry autoConfigurationEntry = getAutoConfigurationEntry(annotationMetadata);
  return StringUtils.toStringArray(autoConfigurationEntry.getConfigurations());
}

protected AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata) {
  // 是否开启了自动装配  判断的是spring.boot.enableautoconfiguration配置
  if (!isEnabled(annotationMetadata)) {
    return EMPTY_ENTRY;
  }
  // 获取注解的属性信息
  AnnotationAttributes attributes = getAttributes(annotationMetadata);
  // 获取所有需要自动装配的类
  List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes);
  // 移除重复的类
  configurations = removeDuplicates(configurations);
  // 移除需要排除的类
  Set<String> exclusions = getExclusions(annotationMetadata, attributes);
  checkExcludedClasses(configurations, exclusions);
  configurations.removeAll(exclusions);
  configurations = getConfigurationClassFilter().filter(configurations);
  fireAutoConfigurationImportEvents(configurations, exclusions);
  return new AutoConfigurationEntry(configurations, exclusions);
}

protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {
  // 获取META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports文件中配置的类
  List<String> configurations = ImportCandidates.load(AutoConfiguration.class, getBeanClassLoader())
    .getCandidates();
  Assert.notEmpty(configurations,
                  "No auto configuration classes found in "
                  + "META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. If you "
                  + "are using a custom packaging, make sure that file is correct.");
  return configurations;
}
// ImportCandidates类中的方法,LOCATION的值为:"META-INF/spring/%s.imports"
public static ImportCandidates load(Class<?> annotation, ClassLoader classLoader) {
  Assert.notNull(annotation, "'annotation' must not be null");
  ClassLoader classLoaderToUse = decideClassloader(classLoader);
  String location = String.format(LOCATION, annotation.getName());
  Enumeration<URL> urls = findUrlsInClasspath(classLoaderToUse, location);
  List<String> importCandidates = new ArrayList<>();
  while (urls.hasMoreElements()) {
    URL url = urls.nextElement();
    importCandidates.addAll(readCandidateConfigurations(url));
  }
  return new ImportCandidates(importCandidates);
}

到这里关于SpringBoot自动装配相关的逻辑已经介绍完了,通过查看源码的方式,我们可以知道:

  • @SpringBootApplication 是一个复合注解,拥有@Configuration、@EnableAutoConfiguration及@ComponentScan的功能
  • @EnableAutoConfiguration 是开启自动装配的注解,在其中定义了@Import(AutoConfigurationImportSelector.class)
  • AutoConfigurationImportSelector 类会在容器启动时获取到META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports文件中配置的类交给Spring进行初始化

3、启动过程

在上面的内容中我们介绍了SpringBoot的自动装配的原理,在接下来的内容中我们介绍下SpringBoot的启动过程。自动装配的逻辑是在@SpringBootApplication中,其启动过程我们应该跟踪SpringApplication.run方法。

跟进这个源码会调用到如下的方法中:

public static ConfigurableApplicationContext run(Class<?>[] primarySources, String[] args) {
  // 创建SpringApplication对象并调用run方法
  return new SpringApplication(primarySources).run(args);
}

SpringApplication对象的创建逻辑如下:

public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
  // 这里传递的resourceLoader为null
  this.resourceLoader = resourceLoader;
  Assert.notNull(primarySources, "PrimarySources must not be null");
  // 这里的primarySources传递的是我们的启动类
  this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
  // 获取应用类型 NONE SERVLET REACTIVE 我们的示例代码是一个web项目  这里的类型是SERVLET
  this.webApplicationType = WebApplicationType.deduceFromClasspath();
  // 获取META-INF/spring.factories配置的BootstrapRegistryInitializer实例
  this.bootstrapRegistryInitializers = new ArrayList<>(
    getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
  // 获取META-INF/spring.factories配置的BootstrapRegistryInitializer实例
  setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));
  // 获取META-INF/spring.factories配置的ApplicationListener实例
  setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
  this.mainApplicationClass = deduceMainApplicationClass();
}

在SpringApplication构造方法中设置应用类型并获取到一些在META-INF/spring.factories中配置的类实例。

应用类型有如下三种:

  • NONE
  • SERVLET
  • REACTIVE

getSpringFactoriesInstances方法最后会调用到SpringFactoriesLoader.load方法中,SpringFactoriesLoader类是Spring SPI的工具类,使用这个类可以获取到所有在META-INF/spring.factories中配置的信息并可按照某个类型获取实例列表。

通过这种方式获取对象的方法,都可以作为我们的扩展点,那么该如何使用呢?我们以BootstrapRegistryInitializer为例,我们在示例代码中定义一个SelfBootstrapRegistryInitializer类,创建META-INF/spring.factories文件并添加配置,代码如下:

public class SelfBootstrapRegistryInitializer implements BootstrapRegistryInitializer {
    @Override
    public void initialize(BootstrapRegistry registry) {
        System.out.println("=============== SelfBootstrapRegistryInitializer ==================");
    }
}
// spring.factories
org.springframework.boot.BootstrapRegistryInitializer=\
  com.xh.sample.spring.boot.SelfBootstrapRegistryInitializer

然后再重启项目,可以看到控制台会打印出我们输出的内容。

介绍完SpringApplication的构造方法后,我们看看这个对象中的run方法逻辑,这个方法中的逻辑就是启动SpringBoot的流程,其源码如下:

public ConfigurableApplicationContext run(String... args) {
  long startTime = System.nanoTime();
  //创建启动上下文对象  这里会调用在上面中获取到的BootstrapRegistryInitializer实例的initialize方法
  DefaultBootstrapContext bootstrapContext = createBootstrapContext();
  ConfigurableApplicationContext context = null;
  // 设置java.awt.headless属性
  configureHeadlessProperty();
  // 获取META-INF/spring.factories中配置的SpringApplicationRunListener实例
  // SpringApplicationRunListener里面提供了starting environmentPrepared contextPrepared 等方法
  // 使用这个扩展点可以完成对启动的各个阶段进行扩展
  SpringApplicationRunListeners listeners = getRunListeners(args);
  // 调用starting方法
  listeners.starting(bootstrapContext, this.mainApplicationClass);
  try {
    ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
    // 准备环境
    ConfigurableEnvironment environment = prepareEnvironment(listeners, bootstrapContext, applicationArguments);
    // 打印banner图  如果自定义banner图的话 只需在resources目录下创建banner.txt文件即可
    Banner printedBanner = printBanner(environment);
    // 创建上下文对象 创建的是AnnotationConfigServletWebServerApplicationContext
    context = createApplicationContext();
    context.setApplicationStartup(this.applicationStartup);
    prepareContext(bootstrapContext, context, environment, listeners, applicationArguments, printedBanner);
    // 启动容器的流程,这里会调用到AbstractApplicationContext.refresh方法中启动spring容器
    refreshContext(context);
    // 这里是个空方法,子类可以实现该方法做些扩展  模版方法
    afterRefresh(context, applicationArguments);
    Duration timeTakenToStartup = Duration.ofNanos(System.nanoTime() - startTime);
    if (this.logStartupInfo) {
      new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), timeTakenToStartup);
    }
    // 容器启动成功  调用listeners的started方法
    listeners.started(context, timeTakenToStartup);
    // 从容器中获取所有的ApplicationRunner  CommandLineRunner对象  调用里面的run方法
    callRunners(context, applicationArguments);
  }
  catch (Throwable ex) {
    if (ex instanceof AbandonedRunException) {
      throw ex;
    }
    handleRunFailure(context, ex, listeners);
    throw new IllegalStateException(ex);
  }
  try {
    if (context.isRunning()) {
      Duration timeTakenToReady = Duration.ofNanos(System.nanoTime() - startTime);
      listeners.ready(context, timeTakenToReady);
    }
  }
  catch (Throwable ex) {
    if (ex instanceof AbandonedRunException) {
      throw ex;
    }
    handleRunFailure(context, ex, null);
    throw new IllegalStateException(ex);
  }
  return context;
}

相应的逻辑在上面的备注中进行了介绍,通过跟踪源码,我们发现SpringBoot中也提供了很多扩展点,我们简单的梳理下如下:

  • 自定义BootstrapRegistryInitializer类 配置到spring.factories文件中
  • 自定义ApplicationContextInitializer类 配置到spring.factories文件中
  • 自定义ApplicationListener类 配置到spring.factories文件中
  • 自定义SpringApplicationRunListener类 配置到spring.factories文件中 用于扩展启动的各个阶段
  • 自定义banner图,在classpath下创建banner.txt文件
  • 自定义ApplicationRunner CommandLineRunner类,使用@Component交给spring容器管理,容器启动完成后调用其run方法

在我们之前的spring搭建的web项目,需要部署到tomcat或者其他的web服务容器中,但我们使用SpringBoot搭建的web应用只需执行一个SpringApplication.run方法便可对外提供web服务了,这是因为在SpringBoot中给我们内置了web容器,这块代码的逻辑在ServletWebServerApplicationContext.onRefresh方法中,看过spring容器启动源码的应该会发现,在容器启动完成后会调用这个方法。这里的代码就不进行粘贴了,在这里会创建WebServer对象,默认使用的是Tomcat,内容的容器有如下几种:

  • TomcatWebServer
  • JettyWebServer
  • NettyWebServer
  • UndertowWebServer
  • UndertowServletWebServer

3、自定义starter

在上面的内容中我们介绍了SpringBoot自动装配的逻辑,我们只需要按照他的规则便可以很方便的自定义一个starter。接下来的内容给出一个简单的示例。在示例代码中我们定义一个单机版redis的客户端redisson。

创建一个redisson-spring-boot-starter的Maven项目,并添加相关依赖如下:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot</artifactId>
  <version>3.0.0</version>
</dependency>

<dependency>
  <groupId>org.redisson</groupId>
  <artifactId>redisson</artifactId>
  <version>3.16.3</version>
</dependency>

创建RedissonProperties类,用于接收相关配置,内容如下:



@ConfigurationProperties(prefix = "redis")
public class RedissonProperties {
    private String host = "localhost";
    private Integer port = 6379;

    public String getHost() {
        return host;
    }

    public Integer getPort() {
        return port;
    }
}

创建RedissonAutoConfiguration类,内容如下:



@Configuration
@EnableConfigurationProperties(value = RedissonProperties.class)
public class RedissonAutoConfiguration {

    @Autowired
    private RedissonProperties redissonProperties;

    @Bean
    public RedissonClient redissonClient() {
        System.out.println("============= 初始化RedissonClient对象 ===============");
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + redissonProperties.getHost() + ":" + redissonProperties.getPort());

        return Redisson.create(config);
    }
}

 

在META-INF/spring目录下创建org.springframework.boot.autoconfigure.AutoConfiguration.imports文件,并将RedissonAutoConfiguration类配置进去,内容如下:



然后使用Maven install到本地仓库,在spring-boot-sample中引入其依赖,然后重启项目,可以在启动日志中看到我们打印的日志,代表我们自定义的starter可以正常使用了。

4、总结

今天的内容就这些了,在本文中介绍了SpringBoot的自动装配原理、启动过程及如何自定义starter。

本文中的示例代码使用的SpringBoot版本为3.0.0,JDK版本为17。

@SpringBootApplication是一个复合注解,是自动装配的关键,AutoConfigurationImportSelector会获取到项目中所有依赖包中META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports文件中配置的类交给spring容器。

SpringBoot启动过程中会启动spring容器和web服务容器,并在其启动过程中有一些扩展点。

海洋CMS admin_notify.php 远程代码执行漏洞复现(CVE-2024-30565) 海洋CMS admin_notify.php 接口处存在远程代码执行漏洞,经过身份验证的远程攻击者可利用该漏洞执行任意代码,写入后门文件,进而控制整个web服务器。 阅读详情

相关推荐

新能源知识库(62)组串式、集中式和高压直挂式

因需多台PCS及独立监控设备,单位功率成本比集中式高15%–20%。高压直挂式因省去变压器,大容量项目成本更低(>5MW时优势显著)。组串式储能、集中式储能和高压直挂式储能是当前主流的三类技术路线,其核心差异源于系统架构和控制逻辑的设计差异。组串式交流侧需变压器升压至10kV/35kV,高压直挂式可直接输出6kV/35kV电压,减少转换损耗。多台小功率PCS并联(每簇独立管理)单台大功率PCS(多簇直流侧并联)环流导致容量衰减(损失5%–8%)无变压器损耗(效率>99%)高压直挂电站(≥10MW)

竹君子之家 1533

Springboot 自动装配流程分析

springboot自动装配流程分析

wdquan19851029的专栏 2349

告别双系统!用Ventoy把Ubuntu 22.04装进U盘,打造你的随身开发环境(附保姆级避坑指南)

本文详细介绍了如何使用Ventoy将Ubuntu 22.04安装到U盘,打造便携式开发环境。通过即插即用的特性,开发者可以在任何x86电脑上快速启动完整的Ubuntu系统,无需配置双系统或虚拟机。文章提供了从硬件准备到系统优化的全流程指南,帮助用户高效创建随身开发环境。

weixin_31569671的博客 371

SpringBoot 自动装配流程以及核心源码剖析

Spring Framework 一直在致力于解决一个问题,就是如何让 bean 管理变得更简单,如何让开发者尽可能的少关注一些基础化的 bean 配置,从而实现自动装配。所谓的自动装配,实际上就是如何自动将 bean 装载到 Ioc 容器中来实际上在 spring 3.x 版本中,Enable 模块驱动注解的出现,已经有了一定的自动装配的雏形,而真正能够实现这一机制,还是在 spirng 4.x 版本中,conditional 条件注解的出现;

vnjohn 博主 > 主线分享后端领域业务设计知识、源码思想、架构设计 4011

【传感器标定(三):激光雷达标定原理与实现详解】

本文系统介绍了激光雷达标定的基本原理与方法。主要内容包括:激光雷达标定的分类(内参标定和外参标定)、坐标系定义和刚体变换数学基础;详细阐述了测距误差和光束方向两种内参标定方法;重点分析了基于目标(平面标定板、三维标定物)和基于运动(手眼标定、点云配准)的外参标定方法;介绍了多传感器联合标定技术及非线性优化、鲁棒标定等实现方法;最后提出了定量和定性两种标定评估体系。为激光雷达在自动驾驶等领域的精确应用提供了系统的标定技术指导。

weixin_47429781的博客 3816

ROS实践(四)机器人SLAM建图(gmapping)

本文介绍了SLAM技术及其实现方法。SLAM(同步定位与地图构建)让机器人在未知环境中通过传感器数据自主定位并构建地图。文章详细讲解了激光雷达、RGBD相机等常用传感器,以及gmapping和map_server这两个ROS功能包的使用方法。重点阐述了SLAM建图实验步骤:配置gmapping节点参数、启动机器人仿真、运行gmapping节点、使用rviz可视化工具、通过键盘遥控机器人完成地图构建并保存。实验结果表明,该方法能有效实现机器人自主建图功能,为后续导航等应用奠定基础。

qq_1033275663的博客 4360

SpringBoot自动装配流程

Springboot的自动装配流程。

weixin_50519232的博客 5278

AD24层次原理图设计避坑指南:如何解决端口连接与自动交叉引用问题

本文深入解析AD24层次原理图设计的核心机制,聚焦端口连接错误、自动交叉引用干扰等常见问题。通过对比自上而下与自下而上设计流程,提供端口类型匹配、命名规范等实用解决方案,并指导如何关闭烦人的红色框线视觉干扰,帮助工程师高效避坑,实现复杂系统的模块化设计。

wdx01234567的博客 623

SpringBoot的自动装配

SpringBoot自动装配原理

99Savage 5694

Hermes 教程 03:Skills 系统

摘要:Hermes Skills是一种自我改进机制,可将解决问题的经验保存为可复用技能文档。v0.13.0版本遵循agentskills.io开放标准,与Claude Skills互通。技能创建流程包括发现问题、创建技能文件、加载使用和优化更新四个阶段。系统提供技能检索和自维护机制(Curator),支持技能媒体路由和多种管理命令。内置技能涵盖开发调试、创意头脑风暴等场景,通过积累技能使Hermes更适应用户需求。

程序猿_三产 748

如何使用 SAP ABAP Development Tool 连接 SAP BTP 上的免费 ABAP 编程环境

在云端环境编写 ABAP 代码会遇到一些限制,比如你无法在云端 ABAP 编程环境进行发生在传统 SAPGUI 里的 Dynpro 和 Screen 编程。部分在 SAPGUI 里使用的 List 处理相关的关键字比如 WRITE,还有 CALL TRANSACTION 等代码,也无法在云端使用。 当然如果大家觉得上面提到的这些限制不会影响自己的 ABAP 学习,就可以继续本文的阅读,使用 ABAP Development Tool 登录云端的 ABAP 编程环境。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1533

一文搞懂SpringBoot启动流程及自动装配

Starters可以理解为启动器,它包含了一系列可以集成到应用里面的依赖包。你可以一站式集成 Spring 及其他技术,而不需要到处找示例代码和依赖包Spring Boot官方的启动器都是以spring-boot-starter-命名的,代表了一个特定的应用类型。第三方的启动器不能以spring-boot开头命名,它们都被Spring Boot官方保留。一般一个第三方的应该这样命名,像mybatis的mybatis-spring-boot-starter。

good___lucky的博客 3840

FineBI学习总结

交叉表:一组作为行标题显示在表的左部,另一组作为列标题显示在表的顶部。连接到数据,如果数据不满足数据分析的需求,先进行自助数据集处理。数据集分类:DB表、SQL、Excel、自助数据集。分组表:将报表中的数据按相同项合并为一组显示。1、数据准备2、制作仪表板3、分享仪表板。左合并:保留左边全部数据,合并右边。右合并:保留右边全部数据,合并左边。上下拼接:上下拼接到一张表数据。3、如何实现拼表:多表拼一张。分组–业务包–数据集–字段。字段分类:数值、文本和日期。目录–仪表板–数据准备。维度:文本和日期类型。

Rsun2018的博客 1567

SpringBoot自动装配原理与启动流程深度解析:从条件注解到自定义Starter

SpringBoot作为Java领域主流的微服务开发框架,其“约定优于配置”的设计理念极大简化了项目搭建与部署。理解其底层机制,尤其是自动装配与条件注解的协作原理,是突破API使用层面、掌握框架内核的关键。本文从SpringBoot的三大核心机制切入,剖析了@SpringBootApplication组合注解、SpringApplication启动流程中环境准备与容器刷新、以及基于@Conditional的条件装配逻辑;同时梳理了配置文件优先级、内嵌Web容器等工程实践要点。通过拆解自定义Starter的编

weixin_31528001的博客 273

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

SpringBoot篇(自动装配原理)

自动装配简单来说就是自动把第三方组件的bean加到IOC容器里,在springboot项目中可以通过在启动类上加@SpringBootApplication注解来实现自动装配,这个注解是一个组合注解,真正实现自动装配的注解是步骤一:main方法中SpringApplication.run(xxx.class,args)的执行流程中有refreshContext(context)。

m0_74823827的博客 958

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

《Spring源码深度解析 郝佳 第2版》SpringBoot体系分析、Starter的原理

往期博客 《Spring源码深度解析 郝佳 第2版》容器的基本实现与XML文件的加载 《Spring源码深度解析 郝佳 第2版》XML标签的解析 《Spring源码深度解析 郝佳 第2版》bean的加载、循环依赖的解决 《Spring源码深度解析 郝佳 第2版》ApplicationContext 《Spring源码深度解析 郝佳 第2版》AOP 《Spring源码深度解析 郝佳 第2版》JDBC、MyBatis原理 目录 ...

xiaosi的博客 1173

02原理篇(D2_SpringBoot 自动装配原理)

自动装配简单来说就是自动把第三方组件的bean加到IOC容器里,在springboot项目中可以通过在启动类上加@SpringBootApplication注解来实现自动装配,这个注解是一个组合注解,真正实现自动装配的注解是@EnableAutoConfiguration。步骤一:main方法中SpringApplication.run(xxx.class,args)的执行流程中有而这个refreshContext(context)内部会解析,配置类上自动装配功能的注解。

m0_74825409的博客 990

深入理解SpringBoot启动流程(包含自动装配和自定义starter是如何被实现)

SpringBoot启动流程

m0_48358308的博客 901

SpringBoot自动装配原理深度解析:从@SpringBootApplication到自定义Starter

自动装配是现代Java框架实现“约定优于配置”理念的核心机制,它通过类路径扫描和条件判断自动组装应用组件。其原理基于Java的SPI扩展机制,结合丰富的条件注解实现精准的依赖注入。这一技术显著提升了开发效率,减少了样板代码,使得开发者能够专注于业务逻辑实现。在微服务架构和模块化开发场景中,自动装配思想被广泛应用于功能模块的动态加载与多环境适配。本文以SpringBoot为例,深入剖析了@SpringBootApplication注解的复合结构、spring.factories文件的注册机制,以及@Condi

weixin_32821533的博客 270

SpringBoot如何自定义启动器

提高:自定义starter 启动器模块是一个 空 jar 文件,仅提供辅助性依赖管理,这些依赖可能用于自动装配或者其他类库; 命名方式: 官方命名: spring-boot-starter-xxx ,比如:spring-boot-starter-web… 自定义命名: xxx-spring-boot-starter ,比如:mybatis-spring-boot-starter 1、在idea中新建个空工程spring-boot-starter-diy 建完以后里面什么都没有 2、新建一个普通M

weixin_49149614的博客 718
上一篇: SpringSecurity的使用:为我们应用增加安全防护
下一篇: 前后端分离的项目,精确到按钮级别的权限控制如何做?
加班不秃顶
博客等级 码龄7年 1821粉丝 599原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址