Spring boot源码分析-AnnotationConfigEmbeddedWebApplicationContext默认web环境下的启动容器(3)
2017-08-20 14:53
1201 查看
4000
看看这个图和AnnotationConfigApplicationContext有什么不一样的地方
1.GenericWebApplicationContext继承了GenericApplicationContext实现了ConfigurableWebApplicationContext接口 我们看一下这个接口,主要提供了web容器也就是servlet容器的相关操作
2.再看AnnotationConfigEmbeddedWebApplicationContext 容器重写了
AbstractApplicationContext的模板方法,在同期中提供了WebApplicationContextServletContextAwareProcessor的处理器,提供了容器注入的功能
EmbeddedWebApplicationContext
其他的功能基本和AnnotationConfigApplicationContext类似 可以去看上一章的解释
Spring boot源码分析-AnnotationConfigEmbeddedWebApplicationContext默认web环境下的启动容器(3)
首先我们看容器的类图,相比于看看这个图和AnnotationConfigApplicationContext有什么不一样的地方
1.GenericWebApplicationContext继承了GenericApplicationContext实现了ConfigurableWebApplicationContext接口 我们看一下这个接口,主要提供了web容器也就是servlet容器的相关操作
2.再看AnnotationConfigEmbeddedWebApplicationContext 容器重写了
AbstractApplicationContext的模板方法,在同期中提供了WebApplicationContextServletContextAwareProcessor的处理器,提供了容器注入的功能
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { }
public class AnnotationConfigEmbeddedWebApplicationContext extends EmbeddedWebApplicationContext { private final AnnotatedBeanDefinitionReader reader; private final ClassPathBeanDefinitionScanner scanner; private Class<?>[] annotatedClasses; private String[] basePackages; ······ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { super.postProcessBeanFactory(beanFactory); if (this.basePackages != null && this.basePackages.length > 0) { this.scanner.scan(this.basePackages); } if (this.annotatedClasses != null && this.annotatedClasses.length > 0) { this.reader.register(this.annotatedClasses); } } }
EmbeddedWebApplicationContext
public class EmbeddedWebApplicationContext extends GenericWebApplicationContext { ······ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor( new WebApplicationContextServletContextAwareProcessor(this)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); } }
其他的功能基本和AnnotationConfigApplicationContext类似 可以去看上一章的解释
相关文章推荐
- Spring boot源码分析-AnnotationConfigApplicationContext非web环境下的启动容器(2)
- Spring-boot Unable to start EmbeddedWebApplicationContext 分析与解决方法
- 从eclipse中导入到IDEA中的SpringBoot项目,启动时报错 Unable to start EmbeddedWebApplicationContext due to missing Em
- SpringBoot报错(十) WARN:ationConfigEmbeddedWebApplicationContext
- Spring-Spring容器启动各项操作窥探(AbstractApplicationContext#refesh()执行逻辑分析)
- spring boot: Bean的初始化和销毁 (一般注入说明(三) AnnotationConfigApplicationContext容器 JSR250注解)
- Spring源码解析 – AnnotationConfigApplicationContext容器创建过程
- Idea 启动Sringboot 报错 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCont
- web.xml AnnotationConfigWebApplicationContext
- ApplicationContext AnnotationConfigApplicationContext WebApplicationContext ConfigurablwWebApplicat
- IDEA启动Spring Boot项目提示Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet...
- IDEA启动spring boot 出现Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCont
- applicationContext.xml中<context:annotation-config> 和 <context:component-scan>的区别
- spring默认启动位置以及contextConfigLocation设置源码解析
- tomcat启动报错:Error configuring application listener of class org.springframework.web.context.ContextLo
- AnnotationConfigApplicationContext的实例化过程
- 【Spring Cloud】Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCon
- 【Spring Cloud】Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletCon
- 从源码看spring applicationContext在web容器中加载过程
- 解释为什么Spring 默认会加载/WEB-INF/applicationContext.xml