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 -
Required Element Summary
Required Elements
-
Element Details
-
value
Class<?> value
-