(1)注解@Conditional的派生注解(Spring注解版原生的@Conditional的作用)
(1)作用:必须是@Conditional指定的条件成立,就给容器中创建组件,添加组件,配置类里面所有的内容才生效
自动配置类必须要在一定的条件下 才能生效
我们如何知道哪些配置类已经生效了?
我们可以通过debug: true来让打印自动匹配报告
打印结果
Positive matches:(自动配置类启用的)
-----------------
AopAutoConfiguration matched:
- @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)
AopAutoConfiguration.ClassProxyingConfiguration matched:
- @ConditionalOnMissingClass did not find unwanted class 'org.aspectj.weaver.Advice' (OnClassCondition)
- @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)
Negative matches:(自动配置类没有启用的)
-----------------
ActiveMQAutoConfiguration:
Did not match:
- @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)