Annotation Type Conditional
@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented public @interface Conditional
Indicates that a component is only eligible for registration when all specified conditions match.A condition is any state that can be determined programmatically before the bean definition is due to be registered (see
Conditionfor details).The
@Conditionalannotation may be used in any of the following ways:- as a type-level annotation on any class directly or indirectly annotated with
@Component, including@Configurationclasses - as a meta-annotation, for the purpose of composing custom stereotype annotations
- as a method-level annotation on any
@Beanmethod
If a
@Configurationclass is marked with@Conditional, all of the@Beanmethods,@Importannotations, and@ComponentScanannotations associated with that class will be subject to the conditions.NOTE: Inheritance of
@Conditionalannotations is not supported; any conditions from superclasses or from overridden methods will not be considered. In order to enforce these semantics,@Conditionalitself is not declared as@Inherited; furthermore, any custom composed annotation that is meta-annotated with@Conditionalmust not be declared as@Inherited.- Since:
- 4.0
- Author:
- Phillip Webb, Sam Brannen
- See Also:
Condition
- as a type-level annotation on any class directly or indirectly annotated with