Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tasdemirbahadir/e240aee71c6645003b9aa32791d21322 to your computer and use it in GitHub Desktop.
Save tasdemirbahadir/e240aee71c6645003b9aa32791d21322 to your computer and use it in GitHub Desktop.
Conditional On Property To Load Beans Sample
@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