代码:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<beans>
<bean class="com.ant.demo.Entity" id="entity"></bean>
<bean class="com.ant.demo.MyBeanFactoryPorstProcessor" id="myBeanFactoryPorstProcessor"></bean>
<bean class="com.ant.demo.MyBeanPostProcessor" id="myBeanPostProcessor"></bean>
</beans>
</beans>
package com.ant.demo;
import org.springframework.stereotype.Component;
@Component
public class Entity {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.ant.demo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
public class MyBeanFactoryPorstProcessor implements BeanFactoryPostProcessor {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
System.out.println(beanFactory);
System.out.println("已经启动");
}
}
package com.ant.demo;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
public class MyBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
System.out.println("before---------");
return beanName+":"+bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("after---------");
return beanName+":"+bean;
}
}
public static void main(String[] args) {
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
Entity bean = classPathXmlApplicationContext.getBean(Entity.class);
System.err.println(bean);
}
springContext执行流程分析: >ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml"); 创建一个ApplicationContext # refresh()(org.springframework.context.ConfigurableApplicationContext.refresh)的doc文档: # Load or refresh the persistent representation of the configuration, - 翻译:加载或者刷新配置(configuration) # which might an XML file, properties file, or relational database schema. - 翻译:加载或者刷新的配置文件有可能是XML文件、properties文件或者关系型数据库 # As this is a startup method, it should destroy already created singletons - 翻译:作为一个启动方法,它应该销毁已经创建的单例实例 # if it fails, to avoid dangling resources. - 翻译:如果销毁失败,避免无用资源 # In other words, after invocation of that method, either all or no singletons at all should be instantiated. - 翻译:总得来说,调用本方法之后,要么全部被实例化,要么一个都不会被实例化 >org.springframework.context.support.AbstractApplicationContext.refresh # doc文档: # Prepare this context for refreshing, - 翻译:为更新操作预先准备上下文环境 # setting its startup date and active flag as well as performing any initialization of property sources. - 翻译:设置启动日志和有效标识以及执行其他的初始化属性 >org.springframework.context.support.AbstractApplicationContext.prepareRefresh # doc文档: # Tell the subclass to refresh the internal bean factory. - 翻译:通知子类更新其内部bean Factory # return the fresh BeanFactory instance - 返回一个全新的BeanFactory >org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory # doc文档: # Configure the factory's standard context characteristics, - 翻译: # such as the context's ClassLoader and post-processors. - 翻译:配置BeanFactory标准上下文信息,例如上下文的Classloader和post-processors等 >org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory # doc文档: # Modify the application context's internal bean factory after its standard initialization. - 翻译:在初始化完BeanFactory的标准上下文信息后,修改上下文的内部beanFactory # All bean definitions will have been loaded,but no beans will have been instantiated yet. - 翻译:所有的bean definitions将会被加载,但是到目前为止没有bean被实例化 # This allows for registering special BeanPostProcessors etc in certain ApplicationContext implementations. - 翻译:这允许在特殊的ApplicationContext实现中注册特殊的BeanPostProcessors等操作 >org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory # doc文档: # Instantiate and invoke all registered BeanFactoryPostProcessor beans,- 翻译:实例化所有已经注册的BeanFactoryPostProcessor,并且调用其postProcessBeanFactory()方法, # respecting explicit order if given. - 翻译如果注册的postProcessBeanFactory有Order(org.springframework.core.annotation.Order)注解,则会严格按照Order定义的顺序来执行 >org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors # doc文档: # Instantiate and register all BeanPostProcessor beans, - 翻译:实例化并注册所有的BeanPostProcessor, # respecting explicit order if given. - 翻译:如果BeanPostProcessor有Order(org.springframework.core.annotation.Order)注解,则会严格按照定义的顺序执行 >org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors # doc文档: # Initialize the MessageSource.Use parent's if none defined in this context. - 翻译:初始化MessageSource,如果没有定义就会默认使用父类的 >org.springframework.context.support.AbstractApplicationContext.initMessageSource # doc文档: # Initialize the ApplicationEventMulticaster. - 翻译:初始化ApplicationEventMulticaster # Uses SimpleApplicationEventMulticaster if none defined in the context. - 翻译:如果没有定义则会使用 SimpleApplicationEventMulticaster >org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster # doc文档: # Template method which can be overridden to add context-specific refresh work. - 翻译:可以被重写的模板方法,在refresh增加一些特殊操作 # Called on initialization of special beans, before instantiation of singletons. - 翻译:在实例化单例之前,初始化特殊的bean的时候被调用 # This implementation is empty. - 翻译:他的实现类是空 >org.springframework.context.support.AbstractApplicationContext.onRefresh # doc文档: # Add beans that implement ApplicationListener as listeners. - 翻译:将实现了ApplicationListener的bean添加为监听器 # Doesn't affect other listeners, which can be added without being beans. - 翻译:可以在不存在bean的时候添加,不会影响其他监听器 >org.springframework.context.support.AbstractApplicationContext.registerListeners # doc文档: # Finish the initialization of this context's bean factory,initializing all remaining singleton beans. - 翻译:完成上下文的beanFactory初始化,初始化剩余的单例bean >org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization # doc文档: #Finish the refresh of this context, invoking the LifecycleProcessor's onRefresh() method and publishing the {@link org.springframework.context.event.ContextRefreshedEvent}. # - 翻译:完成上下文的更新,调用LifecycleProcessor的onRefresh()方法,发布org.springframework.context.event.ContextRefreshedEvent >org.springframework.context.support.AbstractApplicationContext.finishRefresh 1.1 org.springframework.context.support.AbstractApplicationContext.prepareRefresh() # doc文档: # Prepare this context for refreshing, - 翻译:为更新操作预先准备上下文环境 # setting its startup date and active flag as well as performing any initialization of property sources. - 翻译:设置启动日志和有效标识以及执行其他的初始化属性 >org.springframework.context.support.AbstractApplicationContext.prepareRefresh 1.2 org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory() # doc文档: # Tell the subclass to refresh the internal bean factory. - 翻译:通知子类更新其内部bean Factory # return the fresh BeanFactory instance - 返回一个全新的BeanFactory >org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory # doc文档: # This implementation performs an actual refresh of this context's underlying bean factory, - 翻译:这个实现(指AbstractRefreshableApplicationContext)执行真正的beanFactory最底层的更新操作。 # 翻译:停止之前存在bean factory,为上下文的声明周期初始化一个新的bean factory # shutting down the previous bean factory (if any) and initializing a fresh bean factory for the next phase of the context's lifecycle. >org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory >org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory,创建一个BeanFactory实例,实际类型是org.springframework.beans.factory.support.DefaultListableBeanFactory >org.springframework.context.support.AbstractRefreshableApplicationContext.customizeBeanFactory 对创建的BeanFactory做一些定制化配置 # doc文档: # Loads the bean definitions via an XmlBeanDefinitionReader. - 翻译:使用XmlBeanDefinitionReader加载bean definitions >org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions # doc文档: # Initialize the bean definition reader used for loading the bean definitions of this context. - 翻译:初始化一个bean definition reader用于加载bean definitions到当前上下文中 # Default implementation is empty. - 翻译:默认实现为空 # Can be overridden in subclasses, e.g. for turning off XML validation or using a different XmlBeanDefinitionParser implementation. - 翻译:可以被子类重写,例如,为了关闭XML校验或使用一个不同的XmlBeanDefinitionParser解析器实现 >org.springframework.context.support.AbstractXmlApplicationContext.initBeanDefinitionReader - 源码中此处默认xml校验为true # doc文档: # Load the bean definitions with the given XmlBeanDefinitionReader. - 翻译:使用给定的XmlBeanDefinitionReader加载bean definitions # The lifecycle of the bean factory is handled by the {@link #refreshBeanFactory} method; - 翻译:bean factory的生命周期被refreshBeanFactory()方法处理 # hence this method is just supposed to load and/or register bean definitions. - 翻译:因此这个方法只是用来加载和/或注册bean definitions >org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions >org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions - 此处开始根据xml的location(本案例中是applicationContext.xml)进行加载beanDefinition # doc文档 # Load bean definitions from the specified resource location. - 翻译:从指定的resource location中加载bean definitions # The location can also be a location pattern, provided that the ResourceLoader of this bean definition reader is a ResourcePatternResolver. - 翻译:如果bean definition的ResourceLoader是ResourcePatternResolver,那么location可以是一个location表达式(pattern) >org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions >org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions - Load bean definitions from the specified XML file. 使用XmlBeanDefinitionReader从特殊的xml文件中加载BeanDefinition >org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions - Actually load bean definitions from the specified XML file.真实执行从XML文件中加载BeanDefinition的方法 >org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions >org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions # doc文档 # Register each bean definition within the given root {@code <beans/>} element. - 翻译:从 <beans/>节点开始,将注册每一个beanDefinition >org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions # Parse the elements at the root level in the document:"import", "alias", "bean". - 翻译:从文档的根节点解析"import", "alias", "bean"节点 >org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions >org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement - 此处我们可以看到已经开始解析<beans>标签 # 从<beans>标签开始解析,解析到<bean>标签后,来到processBeanDefinition方法 # doc文档: # Process the given bean element, parsing the bean definition and registering it with the registry. # 翻译:处理bean元素,解析并且将其注册 >org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition # Register the given bean definition with the given bean factory. 将给定的beanDefinition注册到给定的bean factory中(此处是DefaultListableBeanFactory) >org.springframework.beans.factory.support.BeanDefinitionReaderUtils.registerBeanDefinition # 此处来到我们的BeanFactory:DefaultListableBeanFactory,对bean进行注册 # 最终bean是注册到org.springframework.beans.factory.support.DefaultListableBeanFactory.beanDefinitionMap中 # beanDefinitionMap是DefaultListableBeanFactory的一个属性,原型是ConcurrentHashMap<beanName,BeanDefinition> >org.springframework.beans.factory.support.DefaultListableBeanFactory.registerBeanDefinition >org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory - 获取上方流程中已经加载完成BeanDefinition的BeanFactory,实际上也就是DefaultListableBeanFactory 1.3 org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory() # doc文档: # Configure the factory's standard context characteristics, - 翻译: # such as the context's ClassLoader and post-processors. - 翻译:配置BeanFactory标准上下文信息,例如上下文的Classloader和post-processors等 >org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory 配置BeanFactory一些信息 1.4 org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory() # doc文档: # Modify the application context's internal bean factory after its standard initialization. - 翻译:在初始化完BeanFactory的标准上下文信息后,修改上下文的内部beanFactory # All bean definitions will have been loaded,but no beans will have been instantiated yet. - 翻译:所有的bean definitions将会被加载,但是到目前为止没有bean被实例化 # This allows for registering special BeanPostProcessors etc in certain ApplicationContext implementations. - 翻译:这允许在特殊的ApplicationContext实现中注册特殊的BeanPostProcessors等操作 >org.springframework.context.support.AbstractApplicationContext.postProcessBeanFactory 1.5 org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors() # doc文档: # Instantiate and invoke all registered BeanFactoryPostProcessor beans,- 翻译:实例化所有已经注册的BeanFactoryPostProcessor,并且调用其postProcessBeanFactory()方法, # respecting explicit order if given. - 翻译如果注册的postProcessBeanFactory有Order(org.springframework.core.annotation.Order)注解,则会严格按照Order定义的顺序来执行 >org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors # org.springframework.beans.factory.config.BeanFactoryPostProcessor的doc文档 # Factory hook that allows for custom modification of an application context's bean definitions, - 翻译:允许用户自定义修改application context中的bean definitions的工厂钩子 # adapting the bean property values of the context's underlying bean factory. - 翻译:调整上下文的基础bean工厂的bean属性值 # Useful for custom config files targeted at system administrators that override bean properties configured in the application context. - 翻译:对于需要在应用上下文中通过子弟应以配置文件覆盖bean的属性的系统管理员而言是非常有用的 # See {@link PropertyResourceConfigurer} and its concrete implementations for out-of-the-box solutions that address such configuration needs. - 翻译:查看PropertyResourceConfigurer,它针对解决此类配置需求的开箱即用解决方案的具体实现 # A {@code BeanFactoryPostProcessor} may interact with and modify bean definitions,but never bean instances. - 翻译:BeanFactoryPostProcessor可能会影响或修改bean definitions,但是永远不会影响bean的实例 # Doing so may cause premature bean instantiation, violating the container and causing unintended side-effects. - 翻译:这样做可能会导致过早实例化bean,破坏容器并导致意外的副作用 # If bean instance interaction is required, consider implementing {@link BeanPostProcessor} instead. - 如果需要和bean实例进行交互,可以考虑实现BeanPostProcessor接口,而不是实现BeanFactoryPostProcessor接口 >org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors 在此处我们可以看到spring会调用所有的BeanFactoryPostProcessor的postProcessBeanDefinitionRegistry方法 >org.springframework.beans.factory.support.AbstractBeanFactory.getBean spring 在此处开始实例化我们自定义的BeanFactoryPostProcessor # doc文档: # Return an instance, which may be shared or independent, of the specified bean. - 翻译:返回一个指定名称的bean的实例,该实例是可以被共享或者独立 >org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean 此处开始具体操作 # 注释:Eagerly check singleton cache for manually registered singletons.检查单例缓存中手动注册的单例对象 >org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton 默认获取单例模式的bean # doc文档: # Return the (raw) singleton object registered under the given name. - 翻译:返回注册到给定名称下注册的bean # Checks already instantiated singletons and also allows for an early reference to a currently created singleton (resolving a circular reference). - 翻译:检查已经创建的单例对象,也允许一个早期引用指向当前创建的单例对象(解决循环依赖问题) >org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton # doc文档 # Mark the specified bean as already created (or about to be created). - 翻译:标记已经被创建的特殊的bean # This allows the bean factory to optimize its caching for repeated creation of the specified bean. - 这允许bean factory对于重复创建的特殊的bean优化他的缓存 >org.springframework.beans.factory.support.AbstractBeanFactory.markBeanAsCreated # doc注释: # Central method of this class: creates a bean instance,populates the bean instance, applies post-processors, etc.这个类(AbstractAutowireCapableBeanFactory)的核心方法,创建bean的实例,填充bean的实例,适用于后置处理器等等 >org.springframework.beans.factory.support.AbstractBeanFactory.createBean # doc文档: # Actually create the specified bean. - 翻译:真实的创建一个指定的bean # Pre-creation processing has already happened at this point, e.g.checking {@code postProcessBeforeInstantiation} callbacks. - 翻译:在此之前已经进行了预处理逻辑,例如:检查postProcessBeforeInstantiation回调 # Differentiates between default bean instantiation, use of a , use of a factory method, and autowiring a constructor.- 翻译:与默认的bean的实例化的区别是,使用factory method,自动注入一个构造函数 >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean #doc文档: # Create a new instance for the specified bean, using an appropriate instantiation strategy:factory method, constructor autowiring, or simple instantiation. # 翻译:为指定的bean创建实例,使用支持的实例化策略,包含工厂方法,构造方法注入或者简单的实例化 >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance - 在此处我们可以看到实际上返回的是一个org.springframework.beans.BeanWrapper对象,支持工厂方法等一系列策略创建bean实例 # doc文档: # Instantiate the given bean using its default constructor.使用默认的构造方法实例化一个bean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getInstantiationStrategy - 在这里返回的实例化策略我们可以看到这里使用的是cglib->instantiationStrategy = new CglibSubclassingInstantiationStrategy(); >org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate >org.springframework.beans.BeanWrapperImpl - 将实例化的对象封装到BeanWrapper中 >org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors - 在此处开始调用我们自定义的的BeanFactoryPosetProcessor的postProcessBeanFactory方法 1.6 org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors() # doc文档: # Instantiate and register all BeanPostProcessor beans, - 翻译:实例化并注册所有的BeanPostProcessor, # respecting explicit order if given. - 翻译:如果BeanPostProcessor有Order(org.springframework.core.annotation.Order)注解,则会严格按照定义的顺序执行 >org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors # doc文档: # Instantiate and register all BeanPostProcessor beans,respecting explicit order if given. - 翻译:实例化并注册所有的BeanPostProcessor,如果定义了顺序,则严格按照给定的顺序执行 >org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors >org.springframework.beans.factory.BeanFactory.getBean - 开始进入创建bean的流程,该流程实际上上方创建BeanFactoryPostProcessor已经分析过,此处我们简单再过一遍关键代码 >org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean >org.springframework.beans.factory.support.AbstractBeanFactory.createBean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance 此处实际上创建了bean之后,把bean包装到wapper中,上方已经讲过 >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean 此处开始实例化bean >org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate 此处开始使用实际的实例化策略开始实例化bean >org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton >org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors >org.springframework.beans.factory.support.AbstractBeanFactory.addBeanPostProcessor - 在此处我们可以看到所有的beanPostProcessor实际上是存放到AbstractBeanFactory中的beanPostProcessors = new CopyOnWriteArrayList<>();属性中 1.7 org.springframework.context.support.AbstractApplicationContext.initMessageSource() # doc文档: # Initialize the MessageSource.Use parent's if none defined in this context. - 翻译:初始化MessageSource,如果没有定义就会默认使用父类的 >org.springframework.context.support.AbstractApplicationContext.initMessageSource 1.8 org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster() # doc文档: # Initialize the ApplicationEventMulticaster. - 翻译:初始化ApplicationEventMulticaster # Uses SimpleApplicationEventMulticaster if none defined in the context. - 翻译:如果没有定义则会使用 SimpleApplicationEventMulticaster >org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster 1.9 org.springframework.context.support.AbstractApplicationContext.onRefresh() # doc文档: # Template method which can be overridden to add context-specific refresh work. - 翻译:可以被重写的模板方法,在refresh增加一些特殊操作 # Called on initialization of special beans, before instantiation of singletons. - 翻译:在实例化单例之前,初始化特殊的bean的时候被调用 # This implementation is empty. - 翻译:他的实现类是空 >org.springframework.context.support.AbstractApplicationContext.onRefresh 2.0 org.springframework.context.support.AbstractApplicationContext.registerListeners() # doc文档: # Add beans that implement ApplicationListener as listeners. - 翻译:将实现了ApplicationListener的bean添加为监听器 # Doesn't affect other listeners, which can be added without being beans. - 翻译:可以在不存在bean的时候添加,不会影响其他监听器 >org.springframework.context.support.AbstractApplicationContext.registerListeners 2.1 org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization() # doc文档: # Finish the initialization of this context's bean factory,initializing all remaining singleton beans. - 翻译:完成上下文的beanFactory初始化,初始化剩余的单例bean >org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization # 注释:Register a default embedded value resolver if no bean post-processor(such as a PropertyPlaceholderConfigurer bean) registered any before : 如果没有bean post-processor,则在注册之前注册一个内置的 value resolver,例如:PropertyPlaceholderConfigurer # at this point, primarily for resolution in annotation attribute values. : 在此刻,主要用于解析属性值 >org.springframework.beans.factory.config.ConfigurableBeanFactory.addEmbeddedValueResolver # 注释:Instantiate all remaining (non-lazy-init) singletons.实例化所有剩余的不是懒加载的单例bean >org.springframework.beans.factory.config.ConfigurableListableBeanFactory.preInstantiateSingletons # 开始一个个的创建bean,此处逻辑我们上方已经分析过此处就不过多分析 >org.springframework.beans.factory.support.AbstractBeanFactory.getBean >org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean >org.springframework.beans.factory.support.AbstractBeanFactory.createBean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance >org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean 如果没有特殊的实例化方式,则采用默认的构造函数实例化 >org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton 2.2 org.springframework.context.support.AbstractApplicationContext.finishRefresh() # doc文档: #Finish the refresh of this context, invoking the LifecycleProcessor's onRefresh() method and publishing the {@link org.springframework.context.event.ContextRefreshedEvent}. # - 翻译:完成上下文的更新,调用LifecycleProcessor的onRefresh()方法,发布org.springframework.context.event.ContextRefreshedEvent >org.springframework.context.support.AbstractApplicationContext.finishRefresh
截图: