目前,我有40个不同的配置文件,所有文件都具有相同的变量和相同的bean。 它们之间的唯一区别是@Value注释获得的内容。
您能帮助我更高效地编写它吗,而无需大量重复配置文件?
我的代码示例(我有大约40个重复的此类):
@Configuration
@Profile("qa")
public class QAAutoDeciderConsumerConfig {
private static final Logger log = LoggerFactory.getLogger(QAAutoDeciderConsumerConfig.class);
@Autowired
private MessageConsumerQA messageConsumer;
@Autowired
private RheousConsumerConfig rheousConsumerConfig;
@Value("${message.key.name}")
private String messageKeyName;
@Value("${max.partition.fetch.bytes}")
private long maxPartitionSize;
@Value("${auto.offset.reset}")
private String autoOffsetReset;
@Value("${QA-AutoDecider.bootstrap-servers}")
private String[] bootStrapUrls;
@Value("${QA-AutoDecider.consumer.client-id}")
private String rheosConsumerClientId;
@Value("${QA-AutoDecider.rheos.services-urls}")
private String rheosServiceUrl;
@Value("${QA-AutoDecider.topic}")
private String rheosTopic;
@Value("${QA-AutoDecider.consumer.group-id}")
private String rheosConsumerGroup;
@Value("${AutoDecider}")
private Boolean runEngine;
@Value("${QAConsumer}")
private Boolean runEnvironment;
@Bean(name = "QA-AutoDecider")
public RheosConsumerExecutor executor() {
return rheousConsumerConfig.executor(runEngine,runEnvironment,bootStrapUrls,rheosTopic,rheosServiceUrl,rheosConsumerClientId, rheosConsumerGroup, messageConsumer, maxPartitionSize, autoOffsetReset);
}
}