Annotation Interface ConditionalOnClass


@Target({TYPE,METHOD}) @Retention(RUNTIME) @Documented @Conditional(org.springframework.boot.autoconfigure.condition.OnClassCondition.class) public @interface ConditionalOnClass
@Conditional that only matches when the specified classes are on the classpath.

A value() can be safely specified on @Configuration classes as the annotation metadata is parsed by using ASM before the class is loaded. Extra care is required when placed on @Bean methods, consider isolating the condition in a separate Configuration class, in particular if the return type of the method matches the target of the condition.

Since:
1.0.0
Author:
Phillip Webb
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The classes names that must be present.
    Class<?>[]
    The classes that must be present.
  • Element Details

    • value

      Class<?>[] value
      The classes that must be present. Since this annotation is parsed by loading class bytecode, it is safe to specify classes here that may ultimately not be on the classpath, only if this annotation is directly on the affected component and not if this annotation is used as a composed, meta-annotation. In order to use this annotation as a meta-annotation, only use the name() attribute.
      Returns:
      the classes that must be present
      Default:
      {}
    • name

      String[] name
      The classes names that must be present.
      Returns:
      the class names that must be present.
      Default:
      {}