Annotation Interface ConditionalOnBean


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

Useful for conditionally registering configurations or beans when certain dependencies exist.

Usage


 @ConditionalOnBean(MyService.class)
 @Bean
 public MyBean conditionalBean() {
     return new MyBean();
 }
 
  • Nested Class Summary

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

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Element Details