SpringBoot

 1.自动装配原理:

在BeanFactoryPostProcessor实现类里面ConfigurationClassPostProcessor,实现自动装配

核心代码 :

@Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        int factoryId = System.identityHashCode(beanFactory);
        if (this.factoriesPostProcessed.contains(factoryId)) {
            throw new IllegalStateException(
                    "postProcessBeanFactory already called on this post-processor against " + beanFactory);
        }
        this.factoriesPostProcessed.add(factoryId);
        if (!this.registriesPostProcessed.contains(factoryId)) {
            // BeanDefinitionRegistryPostProcessor hook apparently not supported...
            // Simply call processConfigurationClasses lazily at this point then.
            processConfigBeanDefinitions((BeanDefinitionRegistry) beanFactory);
        }
         //扫描相关注解类
        enhanceConfigurationClasses(beanFactory);
        beanFactory.addBeanPostProcessor(new ImportAwareBeanPostProcessor(beanFactory));
    }
//ConfigurationClassParser
doProcessConfigurationClass(configClass, sourceClass);
ConfigurationClassPostProcessor.postProcessBeanFactory

相关文章:

  • 2021-04-27
  • 2021-09-10
  • 2021-11-20
  • 2021-11-28
  • 2021-07-20
  • 2021-08-16
  • 2021-07-30
  • 2021-12-22
猜你喜欢
  • 2022-01-13
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-05-22
  • 2021-04-30
相关资源
相似解决方案