title: @Autowired RabbitTemplate is null despite existing @Bean for it
body: <p>In my Spring Boot application, I have such a @Configuration class:</p>
  
  <pre><code> @Configuration
   public class AmqpConnectionConfig {
      @Bean
      @Primary   // has to be here because of https://github.com/spring-projects/spring-boot/issues/2011
      AmqpTemplate inquiryRabbitTemplate(ConnectionFactory factory) {
      RabbitTemplate rabbitTemplate = new RabbitTemplate(factory);
      return rabbitTemplate;
  }
  
  
   @Bean
   ConnectionFactory connectionFactory() {
     ConnectionFactory factory = new  ConnectionFactory();
     // Some host/port/password setup skipped...
     return new CachingConnectionFactory(factory);
   }
  }
  </code></pre>
  
  <p>and I can see in my logs that it runs just fine.</p>
  
  <p>I also have a Quartz job that is configured like</p>
  
  <pre><code> @Service
   public class QuartzMockingJob implements Job {
  
   @Autowired
   AmqpTemplate amqpTemplate;
  
   public QuartzMockingJob() {
      // Instances of Job must have a public no-argument constructor.
  }
  
  public void execute(JobExecutionContext context) throws JobExecutionException {
      // here I create object called "mock"
      if (amqpTemplate!=null) {
          amqpTemplate.convertAndSend("amq.fanout", "my.routing.key", mock);
   }
  } 
  </code></pre>
  
  <p>and in this code amqpTemplate is null. I am confused, what could be a reason for this behaviour? </p>