@SpringBootApplication註解
一、@SpringBootApplication是一個組合註解,加在專案啟動類上。
二、@SpringBootApplication定義:
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {
//略
}
可以看出@SpringBootApplication由三個註解組成。
- @SpringBootConfiguration ,本質是一個@Configuration配置類(類似一個SpringContext.xml檔案),可以通過@Bean定義方法定義Bean。
/**
* Indicates that a class provides Spring Boot application
* {@link Configuration @Configuration}. Can be used as an alternative to the Spring's
* standard {@code @Configuration} annotation so that configuration can be found
* automatically (for example in tests).
* <p>
* Application should only ever include <em>one</em> {@code @SpringBootConfiguration} and
* most idiomatic Spring Boot applications will inherit it from
* {@code @SpringBootApplication}.
*
* @author Phillip Webb
* @author Andy Wilkinson
* @since 1.4.0
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
public @interface SpringBootConfiguration {
//***
}
- @EnableAutoConfiguration 自動配置類
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {
String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration";
/**
* Exclude specific auto-configuration classes such that they will never be applied.
* @return the classes to exclude
*/
Class<?>[] exclude() default {};
/**
* Exclude specific auto-configuration class names such that they will never be
* applied.
* @return the class names to exclude
* @since 1.3.0
*/
String[] excludeName() default {};
}
- @ComponentScan 元件掃描類. 類似SpringContext.xml檔案zhong的 <context:component-scan>
@Repeatable(ComponentScans.class)
public @interface ComponentScan {
//
}
相關文章
- 使用 @SpringBootApplication 註解Spring BootAPP
- 神秘又強大的@SpringBootApplication註解Spring BootAPP
- springboot系列文章之SpringBootApplication註解Spring BootAPP
- 精盡Spring Boot原始碼分析 - 剖析 @SpringBootApplication 註解Spring Boot原始碼APP
- 簡明易理解的@SpringBootApplication註解原始碼解析(包含面試提問)Spring BootAPP原始碼面試
- SpringBoot 中 @SpringBootApplication註解背後的三體結構探祕Spring BootAPP
- springboot自動裝配(1)---@SpringBootApplication註解怎麼自動裝配各種元件Spring BootAPP元件
- JAVA-註解(2)-自定義註解及反射註解Java反射
- 註解專題(一)Java元註解,內建註解Java
- Java註解-後設資料、註解分類、內建註解和自定義註解Java
- Spring5:@Autowired註解、@Resource註解和@Service註解Spring
- Java中的註解-自定義註解Java
- 【Spring註解】事務註解@TransactionalSpring
- Java註解詳解「註解專案實戰」Java
- Java註解解析-搭建自己的註解處理器(CLASS註解使用篇)Java
- 深入理解 Java 註解 [元註解(一)]Java
- 【String註解驅動開發】你瞭解@PostConstruct註解和@PreDestroy註解嗎?Struct
- 註解 & 反射反射
- @import註解Import
- java註解Java
- 註解 javaJava
- 註解和註釋區別
- Lombok 註解詳解Lombok
- Java註解詳解Java
- Java 註解詳解Java
- Java ”框架 = 註解 + 反射 + 設計模式“ 之 註解詳解Java框架反射設計模式
- Spring 註解程式設計之模式註解Spring程式設計模式
- 對於 @Autowired註解和@service註解的理解
- 【Android】註解框架(二) 基礎知識(Java註解)& 執行時註解框架Android框架Java
- SwaggerAPI註解詳解,以及註解常用引數配置SwaggerAPI
- Spring 各種註解備註Spring
- Java中的註解-自定義註解處理器Java
- @FeignClient註解詳解client
- springmvc註解詳解SpringMVC
- Java註解(Annotation)詳解Java
- Spring註解詳解Spring
- 註解開發
- 註解基礎