使用功能切换在应用配置中创建 bean 的示例:
@RefreshScope
@Configuration
@Order(1)
class AppConfig {
@Bean
@Autowired
public FeatureProvider featureProvider() {
return new EnumBasedFeatureProvider(FeatureToggle.class);
}
@Bean
@Autowired
ProjectAccess getProjectAccess(DataSource dataSource, HazelcastLocator hazelcastLocator) {
if(FeatureToggle.MY_TOGGLE_NAME.isActive()) {
return new MyTestClass();
}
else {
return new YourTestClass();
}
}
}