【专题-SpringBoot】SpringBoot的启动流程与工作原理([Special Topic – springboot] startup process and working principle of springboot)

@SpringBootApplication
public class SpringBootStudyConfigApplication
    public static void main(String[] args) {
        SpringApplication.run(SpringBootStudyConfigApplication.class, args);
    }
}

@SpringBootApplication 注解

SpringBoot中只需要有@SpringBootApplication这个注解,有了它马上就能够让整个应用跑起来。实际上它只是一个组合注解,包括:@Configuration配置类,@ComponentScan类包扫描,@EnableAutoConfiguration根据需求自动加载相关的bean。

如果没有指定包名,默认是加这个注解的类所在的包及子包下。

————————
@SpringBootApplication
public class SpringBootStudyConfigApplication
    public static void main(String[] args) {
        SpringApplication.run(SpringBootStudyConfigApplication.class, args);
    }
}

@SpringBootApplication 注解

Springboot only needs the annotation @ springbootapplication, which can make the whole application run immediately. In fact, it is just a composite annotation, including: @ configuration configuration class, @ componentscan class package scanning, @ enableautoconfiguration automatically loads relevant beans according to requirements.

If no package name is specified, the default is under the package and sub package of the class with this annotation.