一、启动入口 EnableDubbo注解

EnableDubbo内含有注解@DubboComponentScan,而@Import(DubboComponentScanRegistrar.class)包含在注解中,那让跟进去看看这个class类做了什么

实现spring的ImportBeanDefinitionRegistrar重写了registerBeanDefinitions方法,主要做了三件事:
- 1.找出要扫描的路径包集合
- 2.注册ServiceAnnotationBeanPostProcessor,而这里面又会注册到一个很关键的类DubboBootstrapApplicationListener
- 3.注册一些要用到的类
二、dubbo的正式启动

DubboBootstrapApplicationListener实现了aplicationListener,在spring contextRefreshed事件结束后执行,走到DubboBootstrap的start方法开始dubbo的初始化服务发布之路
public DubboBootstrap start() {
if (started.compareAndSet(false, true)) {
initialize();
if (logger.isInfoEnabled()) {
logger.info(NAME + " is starting...");
}
exportServices();
if (!isOnlyRegisterProvider() || hasExportedServices()) {
exportMetadataService();
registerServiceInstance();
}
referServices();
if (logger.isInfoEnabled()) {
logger.info(NAME + " has started.");
}
}
return this;
}
```