Detailed notes spring 4.x @Condition

When the container has @ConditionalOnBean under conditions specified in Bean
When the container has @ConditionalOnClass under conditions specified class
@ConditionalOnExpression expression as the determination condition based SpEL
@ConditionalOnJava JVM version as the determination condition based on
@ConditionalOnJndi Find the specified location under conditions exist JDNI
@ConditionalOnMissingBean case when the container is not specified Bean
@ConditionalOnMissingClass case where the container is not specified class
Under current conditions @ConditionalOnNotWebApplication item is not a Web project
Whether @ConditionalOnProperty specified attributes specified value
@ConditionalOnResource whether the value specified classpath
@ConditionalOnSingleCandidate currently specified Bean is only one in a container, or specify a preferred although there are more, but Bean
@ConditionalOnWebApplication current project is a case of Web projects

Annotations are a combination of the above @Conditional yuan notes, just use different conditions  

SpEl expression connection https://www.jianshu.com/p/e0b50053b5d3

It is worth saying that the Spring Boot Configuration is in effect controlled by @ConditionalOnProperty

 

Guess you like

Origin www.cnblogs.com/chenchengyi/p/11164873.html