title: Using a mocked object in the actual application (Not test)
body: <p>This is my first question here! 
  Im trying to use IBM MQ API(allclient) in my spring-boot application, however, I don't have MQ available in all environments. 
  I have configured spring to create an MQQueueManager bean, which works fine when I have an actual queue manager running, but when I don't, I cant start my application. 
  I wanted to remove the MQQueueManager dependency from my application for when I/ others don't have a queue manager.  </p>
  
  <p>To add to the problem this bean is injected into another bean, so removing the MQQueueManager config class would still break my other bean. </p>
  
  <p>I have tried the below code, which I though would load the Mock bean instead of the real bean. </p>
  
  <p>src/main/java/com/app/config</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration 
  @Profile("development")
  public class MqConfig { 
  
      @Bean 
      public MQQueueManager connectToQueue(){
        //connection to real QMGR 
       }
  
  }
  </code></pre>
  
  <p>src/test/java/com/app/config</p>
  
  <pre class="lang-java prettyprint-override"><code>@Configuration 
  @Profile("test")
  public class MqConfig { 
  
      @Bean
      public MQQueueManager connectToQueue(){
        return Mockito.mock(MQQueueManager.class); 
       }
  
  }
  </code></pre>
  
  <p>Spring is unable to find any MQQueueManager beans so the app fails to start.</p>