调试源码
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Entrance.class);
进入AnnotationConfigApplicationContext类构造方法
通过this();调用父类构造方法
这里父类构造方法已自身为参数初始化了
this.reader = new AnnotatedBeanDefinitionReader(this); this.scanner = new ClassPathBeanDefinitionScanner(this);
在初始化的过程中进入了
DefaultListableBeanFactory类的registerBeanDefinition()方法, 将spring自身依赖的Bean注册到容器中
下面在看register(annotatedClasses);方法;它进入了AnnotatedBeanDefinitionReader类的doRegisterBean()方法中,给定义Bean的类注册Bean