Annotation Interface ConditionalOnProperty


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Conditional(Condition.class) public @interface ConditionalOnProperty
Conditional that only matches when a specific property is set and matches a given pattern.

Usage


 @ConditionalOnProperty(value = "feature.enabled")
 @Bean
 public FeatureService featureService() {
     return new FeatureService();
 }
 

The pattern is a regular expression (defaults to ".+", i.e., non-empty).

  • Nested Class Summary

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

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
     
  • Element Details