spring_reference/IV. Spring Boot features/36.3.2. Bean conditions.md

6 lines
626 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.3.2. Bean条件
@ConditionalOnBean和@ConditionalOnMissingBean注解允许根据特定beans是否出现来跳过配置。你可以使用value属性来指定beansby type也可以使用name来指定beansby name。search属性允许你限制搜索beans时需要考虑的ApplicationContext的层次。
**注**:当@Configuration类被解析时@Conditional注解会被处理。Auto-configure @Configuration总是最后被解析在所有用户定义beans后面然而如果你将那些注解用到常规的@Configuration类需要注意不能引用那些还没有创建好的bean定义。