Demonstrates how to feature flag spring beans
There are three @Component spring beans viz.
FeatureOne.javaFeatureTwo.javaFeatureThree.java
And an `application.yml` spring config file which has feature flags' values.
Note that all these components are annotated with `@ConditionalOnProperty` annotation.
Based on which feature should be enabled, set the value of feature flags in application.yml file.
- Run
./gradlew bootRunon Mac/Linux orgradlew.bat bootRunon Windows terminal. - On the console, verify that the enabled spring bean names are printed.
All the three components extend from a base class Feature. This is not essential to create feature flagged beans.
I created a common base class type for all these components so that it becomes easier for me to only fetch beans that I created for printing.
See FeatureFlaggingApplication#printEnabledBeanNames() method to understand this.