Springboot启动扫描包的原理
某厂面试归来,发现自己落伍了!>>> 参考链接1 参考链接2 所参照代码为Springboot2.1.1 默认情况下,扫描范围是主类xxxApplication所在包及其子目录,可以在后面的具体实现中看到。 从主类中的 SpringApplication.run(xxxApplication.class, args); 一直点击进入run方法的实现,这里可以看到run方法里有几个关于context的方法分别是: createApplicationContext() prepareContext(xxx,xx) refreshContext(context) public ConfigurableApplicationContext run ( String . . . args ) { . . . try { . . . context = createApplicationContext ( ) ; . . . prepareContext ( context , environment , listeners , applicationArguments , printedBanner ) ; refreshContext ( context ) ; . . . . catch ( Throwable ex ) { } 逐个分析: 1