springboot自动装配,springboot启动流程,redisson

1. springboot自动装配

https://baijiahao.baidu.com/s?id=1765296199559553852&wfr=spider&for=pc

SpringBoot自动装配原理:

@EnableAutoConfiguration注解导入AutoConfigurationImportSelector类。
selectImports方法调用SpringFactoriesLoader.loadFactoryNames()扫描所有jar下面的对应的META-INF/spring.factories文件.
把所有在spring.factories文件中扫描到的全类名进行实例化加载到IOC容器中。

SpringBoot自动装配说白了就是自动帮我们把第三方的组件装配到IOC容器,不需要再手动的去写Bean相关的配置,因为大多数配置SpringBoot已经帮我们约定好了,也就是约定大于配置的理念。

2. springboot启动流程

https://blog.csdn.net/weixin_40496191/article/details/109098491
--------------------------------创建springbootApplication对象---------------------------------------------
1. 创建springbootApplication对象springboot容器初始化操作
2. 获取当前应用的启动类型。
	注1:通过判断当前classpath是否加载servlet类,返回servlet web启动方式。
	注2:webApplicationType三种类型:
		1.reactive:响应式启动(spring5新特性)
		2.none:即不嵌入web容器启动(springboot放在外部服务器运行 )
		3.servlet:基于web容器进行启动
3. 读取springboot下的META-INFO/spring.factories文件,获取对应的ApplicationContextInitializer装配到集合
4. 读取springboot下的META-INFO/spring.factories文件,获取对应的ApplicationListener装配到集合
5. mainApplicationClass,获取当前运行的主函数
6. 
------------------调用springbootApplication对象的run方法,实现启动,返回当前容器的上下文----------------------------------------------
7. 调用run方法启动
8. StopWatch stopWatch = new StopWatch(),记录项目启动时间
9. getRunListeners,读取META-INF/spring.factores,将SpringApplicationRunListeners类型存到集合中
10. listeners.starting();循环调用starting方法
11. prepareEnvironment(listeners, applicationArguments);将配置文件读取到容器中
		读取多数据源:classpath:/,classpath:/config/,file:./,file:./config/底下。其中classpath是读取编译后的,file是读取编译前的
		支持yml,yaml,xml,properties
12. Banner printedBanner = printBanner(environment);开始打印banner图,就是sprongboot启动最开头的图案
13. 初始化AnnotationConfigServletWebServerApplicationContext对象
14. 刷新上下文,调用注解,refreshContext(context);
15. 创建tomcat
16. 加载springmvc
17. 刷新后的方法,空方法,给用户自定义重写afterRefresh()
18. stopWatch.stop();结束计时
19. 使用广播和回调机制告诉监听者springboot容器已经启动化成功,listeners.started(context);
20. 使用广播和回调机制告诉监听者springboot容器已经启动化成功,listeners.started(context);
21. 返回上下文

3. Redisson实现Redis分布式锁的原理分析

https://blog.csdn.net/a1036645146/article/details/116192950

你可能感兴趣的:(微服务,spring,boot,后端,java)