title: Error creating bean with name 'rabbitTemplate' - CloudAMQP with Spring Boot
body: <p>So I want to create a simple queue where I just send data every time I send a text message into it.</p>
  
  <p>I'm using CloudAMQP, their documentation gives me a Java code to use, which does work when running on its own, the issue comes when I add Spring Boot to the mix, this is the class:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class CloudAMQPService {
  
      private final static String QUEUE_NAME = "HEREGOESQUEUENAME";
  
      public void sendMessage(String message) throws Exception {
          String uri = System.getenv("CLOUDAMQP_URL");
          if (uri == null) uri = "HEREGOESURL";
          ConnectionFactory factory = new ConnectionFactory();
          factory.setUri(uri);
          factory.setConnectionTimeout(30000);
          Connection connection = factory.newConnection();
          Channel channel = connection.createChannel();
  
          channel.queueDeclare(QUEUE_NAME, false, false, false, null);
          channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
          System.out.println(" [x] Sent '" + message + "'");
          channel.close();
          connection.close();
      }
  }
  </code></pre>
  
  <p>I can actually send the message when running it on a framework free Java application,  but if I try to call it using Spring Boot I get this error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rabbitTemplate' defined in class path resource [org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration$RabbitTemplateConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.amqp.rabbit.core.RabbitTemplate] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
  at 
  
  org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:570) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
      at pe.edu.upc.integracion.IntegracionApplication.main(IntegracionApplication.java:28) [classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144]
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.8.RELEASE.jar:2.1.8.RELEASE]
  Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.amqp.rabbit.core.RabbitTemplate] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
      at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:507) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:367) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:432) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:406) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:333) ~[spring-orm-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1077) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:567) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      ... 20 common frames omitted
  Caused by: java.lang.NoClassDefFoundError: com/rabbitmq/client/ConfirmCallback
      at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_144]
      at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_144]
      at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_144]
      at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:489) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
      ... 26 common frames omitted
  Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.ConfirmCallback
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_144]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_144]
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_144]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_144]
      ... 30 common frames omitted
  
  
  Process finished with exit code 0
  </code></pre>
  
  <p>Tried adding the restTemplate as an autowired on the class but to no avail, it still gives me an error, not sure what is going on</p>