SpringBoot主启动类执行流程

 //将SpringBoot应用启动
        //SpringApplication类的实例化
        /*推断这个应用的类型时普通的项目(运行完结束),还是web项目(等待请求)
        @SuppressWarnings({ "unchecked", "rawtypes" })
	public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
		this.resourceLoader = resourceLoader;
		Assert.notNull(primarySources, "PrimarySources must not be null");
		this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
		this.webApplicationType = WebApplicationType.deduceFromClasspath();
		this.bootstrapRegistryInitializers = new ArrayList<>(
				getSpringFactoriesInstances(BootstrapRegistryInitializer.class));
		setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));
		setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
		this.mainApplicationClass = deduceMainApplicationClass();
	}
        * 查找并加载所有可用初始化器,设置到initializers属性中
        * 找出所有的应用程序监听器,设置到listeners属性中
        * 推断并设置main方法的定义类,找到运行的主类*/
        //run方法实行   开启一个服务/进程 类似于Docker
posted @ 2021-12-01 09:42  一刹流云散  阅读(177)  评论(0编辑  收藏  举报