SpringBoot基本原理!
发表于更新于
容器启动

SpringBoot
一般是指定容器启动Main
方法,然后以命令行方式启动Jar
包。
1 2 3 4 5 6
| @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
|
@SpringBootApplication
注解:
1 2 3 4 5 6 7 8 9 10
| @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) }) public @interface SpringBootApplication {
|
核心注解:
@EnableAutoConfiguration
:
- 借助
@Import
的帮助,将所有符合自动配置条件的Bean
定义加载到IOC
容器。
1 2 3 4 5 6 7 8
| @SuppressWarnings("deprecation") @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @AutoConfigurationPackage @Import(EnableAutoConfigurationImportSelector.class) public @interface EnableAutoConfiguration {
|
