Spring Boot原理解析
传统的Spring使用
a.需要使用配置文件或者是xml文件来进行包扫描
比如xml文件+注解注入:
<context:component-scan backpage = "org.lanqiao"/>
@Component @Service @Respository @Controller ===》注入Ioc容器当中
b.需要手动的导入依赖包才能使用,导入的十分繁琐 <dependency>
SpringBoot的使用
使用到的注解:
@SpringBootApplication (使用了相应的注解就会注入到Ioc容器)
== @SpringBootConfiguration(声明这是一个配置类)
== @EnableAutoConfigurationPackage(核心)(启用自动配置)
====@AutoConfigurationPackage(自动包扫描)
======Registrar 类下的方法 PackageImports(metadata)).getPackageNames() (获取对象所在的位置的包名)
====@Import(AutoConfigurationImportSelelctor.class)
======AutoConfigurationImportSelelctor=>loadFactoryNames=>META-INF/spring.factories(找到对应的配置)