2018-08-09-springboot

https://blog.csdn.net/cqdz_dj/article/details/51911543

https://my.oschina.net/bigsloth/blog/754486

https://blog.csdn.net/qq_19674905/article/details/79367921

https://www.jianshu.com/p/4e1cab2d8431

一、springboot起始类

@RestController 告诉Spring该类用于处理Web请求,并且把结果直接返回给调用者

@RequestMapping 提供路由信息,它告诉Spring请求对应路径的方法

@EnableAutoConfiguration 告诉 Spring Boot 根据项目中添加的依赖进行相关的配置

main方法是一个java程序的入口,它委托 Spring Boot 的SpringApplication类调用其run方法引导Spring以及Tomcat容器的执行

二、springboot的起始jar包

2018-08-09-springboot_第1张图片
starter-web包含的功能
2018-08-09-springboot_第2张图片
springboot两个重要关键字


三、@EnableAutoConfiguration的作用

2018-08-09-springboot_第3张图片


借助EnableAutoConfigurationImportSelector,

@EnableAutoConfiguration可以帮助SpringBoot应用

将所有符合条件的@Configuration配置都加载到当前SpringBoot创建并使用的IoC容器。就像一只“八爪鱼”一样。

借助于Spring框架原有的一个工具类:SpringFactoriesLoader的支持,@EnableAutoConfiguration可以智能的自动配置功效才得以大功告成!


2018-08-09-springboot_第4张图片

所以,@EnableAutoConfiguration自动配置的魔法骑士就变成了:

从classpath中搜寻所有的META-INF/spring.factories配置文件,

并将其中org.springframework.boot.autoconfigure.EnableutoConfiguration对应的配置项通过反射(Java Refletion)实例化

对应的标注了@Configuration的JavaConfig形式的IoC容器配置类,

然后汇总为一个并加载到IoC容器

四、启动注解@SpringBootApplication

入口类Application的启动注解@SpringBootApplication

2018-08-09-springboot_第5张图片
2018-08-09-springboot_第6张图片
2018-08-09-springboot_第7张图片


通过自定义PropertySourceLoader来自定义配置加载

你可能感兴趣的:(2018-08-09-springboot)