Override configuration prefix on IBM MQ Starter - change prefix from ibm.mq to infrastructure.ibm.mq

Viewed 112

MQ starter has

@ConfigurationProperties(prefix = "ibm.mq")
public class MQConfigurationProperties {

I want to change the config prefix to infrastructure.ibm.mq and the rest of the hiearchy on the config is the same

I want to avoid changing the MQConfiguration.java file, and recompiling, I just want to use the starter as is, but use a slightly different config prefix

1 Answers

This is one way I was able to override it. The @Primary means that this takes precedence. Otherwise you get errors about finding 2 beans where only a single is accepted.

  @Bean
  @Primary
  @ConfigurationProperties(prefix = "my.local.prefix")
  public MQConfigurationProperties localConfigurationProperties() {
    return new MQConfigurationProperties();
  }
Related