Last active
April 23, 2020 08:07
-
-
Save tasdemirbahadir/e240aee71c6645003b9aa32791d21322 to your computer and use it in GitHub Desktop.
Conditional On Property To Load Beans Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class FeatureTogglingBeans { | |
@Bean | |
@ConditionalOnProperty( | |
name = "feature.version", | |
havingValue = "v1", | |
matchIfMissing = true) | |
public SampleService sampleService() { | |
return new DefaultSampleService(); | |
} | |
@Bean | |
@ConditionalOnProperty( | |
name = "feature.version", | |
havingValue = "v2") | |
public SampleService sampleService() { | |
return new NewFeatureSampleService(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment