作用
必须是@Conditional指定的条件成立,才会给容器中添加组件,配置类中的所有内容才会生效
自动配置类在一定条件下才能生效
我们如何才能知道哪些自动配置类生效了
我们可以启用
debug=true
属性来让控制台打印自动配置报告,这样就可以很方便的知道哪些自动配置类生效了
=========================
AUTO-CONFIGURATION REPORT
=========================
Positive matches: // 自动配置类启动的
-----------------
AopAutoConfiguration matched:
- @ConditionalOnClass found required classes 'org.springframework.context.annotation.EnableAspectJAutoProxy', 'org.aspectj.lang.annotation.Aspect', 'org.aspectj.lang.reflect.Advice'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
- @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)
Negative matches: // 自动配置类没有启动的
-----------------
ActiveMQAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.ActiveMQConnectionFactory' (OnClassCondition)
Exclusions:
-----------
None
Unconditional classes:
----------------------
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration