标签:correct for tty 老师 gets inf def div sel
说说springboot启动机制
https://ke.qq.com/webcourse/index.html#cid=333216&term_id=100395479&taid=2568313133929888&vid=5285890788262993749
通过@EnableAutoConfiguration 加载
@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(
@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @AutoConfigurationPackage @Import({EnableAutoConfigurationImportSelector.class}) //------>通过 public @interface EnableAutoConfiguration { String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration"; Class<?>[] exclude() default {}; String[] excludeName() default {}; }
@Import 把一个类通过这种方式交给Spring容器管理
@Import({EnableAutoConfigurationImportSelector.class}) 点进去看这个类,再看它的父类
@Deprecated
public class EnableAutoConfigurationImportSelector extends AutoConfigurationImportSelector {
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) { List<String> configurations = SpringFactoriesLoader.loadFactoryNames(this.getSpringFactoriesLoaderFactoryClass(), this.getBeanClassLoader()); Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct."); return configurations; }
看出它回到这个包的路径下读取这个spring.factories配置文件:重点看这个三个
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration这个文件中,有启动Tomcat
老师的版本是2.0
本人这个org.springframework.boot.autoconfigure 的jar包是1.5.10... 启动tomcat如下代码
WebMvcAutoConfiguration.java 文件中:主要通过enablewebmvc注解 把springmvc加载进来
手写spirngboot ,启动验证
标签:correct for tty 老师 gets inf def div sel
原文地址:https://www.cnblogs.com/rogge7/p/12986405.html