spring_reference/IV. Spring Boot features/36.1. Understanding auto-co...

6 lines
561 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 36.1. 理解auto-configured beans
从底层来讲auto-configured是使用标准的@Configuration实现的类另外的@Conditional注解用来约束在什么情况下使用auto-configuration。通常auto-configuration类使用@ConditionalOnClass和@ConditionalOnMissingBean注解。这是为了确保只有在相关的类被发现和你没有声明自己的@Configuration时才应用auto-configuration。
你可以浏览spring-boot-autoconfigure的源码查看我们提供的@Configuration类查看META-INF/spring.factories文件