Annotation Interface ConditionalOnMissingBean


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Conditional(Condition.class) public @interface ConditionalOnMissingBean
Conditional that only matches when a bean of the specified type is not present in the context.

This is commonly used to allow user-defined overrides of default beans.

Usage


 @ConditionalOnMissingBean
 @Bean
 public MyFallbackService myService() {
     return new MyFallbackService();
 }
 
If no type is specified, the return type of the method is used.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details

    • value

      Class<?> value
      Default:
      void.class