title: org.springframework.beans.factory.BeanCreationException:
body: <p>Guys when I start my spring application I get an error and Tomcat server does not start.
  Here's my work below (In main app, reading part and hibernate part are  working fine)</p>
  
  <p>Main Application</p>
  
  <pre><code>package com.javainuse;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import org.apache.poi.ss.usermodel.Row;
  import org.apache.poi.xssf.usermodel.XSSFSheet;
  import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  import org.hibernate.Session;
  import org.hibernate.SessionFactory;
  import org.hibernate.Transaction;
  import org.hibernate.cfg.AnnotationConfiguration;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class SpringBootHelloWorldApplication {
  
      public static void main(String[] args) throws IOException {         
                  System.out.println("Debug Print");
                   Read();
  
  
          SpringApplication.run(SpringBootHelloWorldApplication.class, args);
  
      }
  
      private static void Read() throws IOException {
            System.out.println("Hacked by?");
          SessionFactory sf = new AnnotationConfiguration().configure("hibernate.cfg.xml").buildSessionFactory();
          Session session = sf.openSession();
          FileInputStream file = new FileInputStream(new File("C:/Users/MONSTER/Desktop/Hello.xlsx")); 
          XSSFWorkbook workbook = new XSSFWorkbook(file); 
          XSSFSheet sheet = workbook.getSheetAt(0); 
          Row row;
          for(int i=1; i&lt;=sheet.getLastRowNum(); i++){ 
              row = (Row) sheet.getRow(i);  //sheet number
  
  
                  String id;
                  if( row.getCell(0)==null) { id = "0"; }
                  else id= row.getCell(0).toString();
  
                     String name;
                  if( row.getCell(1)==null) { name = "null";}  
                     else name = row.getCell(1).toString();   //else copies cell data to name variable
  
                     String phone;
                  if( row.getCell(2)==null) { phone = "null";   }
                     else  phone   = row.getCell(2).toString();
          Transaction t = session.beginTransaction();
          Customer std = new Customer();
          std.setId((int) Double.parseDouble(id));
          std.setName(name);
          std.setPhone(phone);
          System.out.println(std.getId()+" "+std.getName()+" "+std.getPhone());
          session.saveOrUpdate(std);
          t.commit();     
          }
  
          file.close();
                  System.out.println("Completed!");
  
      }
  
  
  
      }
  </code></pre>
  
  <p>Customer class</p>
  
  <pre><code>package com.javainuse;
  
  import java.io.Serializable;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  @Entity
  @Table(name="customer", schema="excel")
  public class Customer  {
      @Id
   //  @GeneratedValue(strategy = GenerationType.AUTO)
  private int id;
          @Column
  private String name;
          @Column
  private String phone;
  public int getId() {
      return id;
  }
  public void setId(int id) {
      this.id = id;
  }
  public String getName() {
      return name;
  }
  public void setName(String name) {
      this.name = name;
  }
  public String getPhone() {
      return phone;
  }
  public void setPhone(String phone) {
      this.phone = phone;
  }
  public Customer(int id, String name, String phone) {
      super();
      this.id = id;
      this.name = name;
      this.phone = phone;
  }
  public Customer() {
      super();
  }
  
  
  
  
  
  }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>package com.javainuse.controllers;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  public class helloController {
  
      @RequestMapping("/welcome.html")
      public ModelAndView firstPage() {
          return new ModelAndView("xd"); 
      }
  
  }
  </code></pre>
  
  <p>Pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;YEA&lt;/groupId&gt;
      &lt;artifactId&gt;YEA&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;YEA&lt;/name&gt;
      &lt;description&gt;Demo YEA for Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.4.1.RELEASE&lt;/version&gt;
          &lt;relativePath /&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
                  &lt;dependency&gt;
      &lt;groupId&gt;javax.transaction&lt;/groupId&gt;
      &lt;artifactId&gt;jta&lt;/artifactId&gt;
      &lt;version&gt;1.0.1B&lt;/version&gt;
  &lt;/dependency&gt;
  
  
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
          &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.data&lt;/groupId&gt;
        &lt;artifactId&gt;spring-data-jpa&lt;/artifactId&gt;
        &lt;version&gt;1.11.4.RELEASE&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
        &lt;artifactId&gt;poi&lt;/artifactId&gt;
        &lt;version&gt;3.14&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.apache.poi&lt;/groupId&gt;
        &lt;artifactId&gt;poi-ooxml&lt;/artifactId&gt;
        &lt;version&gt;3.14&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
        &lt;version&gt;3.2.6.ga&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
        &lt;artifactId&gt;hibernate-annotations&lt;/artifactId&gt;
        &lt;version&gt;3.3.1.GA&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
       &lt;dependency&gt;
        &lt;groupId&gt;javax&lt;/groupId&gt;
        &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
        &lt;version&gt;7.0&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
       &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      ... 26 common frames omitted
  Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
      ... 28 common frames omitted
  </code></pre>