title: EntityManagerFactory not found in SpringBoot
body: <p>I am trying to create a login for employees, using MySQL and SpringBoot. I made my code work using an in-memory Database, but as soon as I switched my code to MySQL, it stopped working. This project is a Frankenstein, so I am not sure whether some of my components can work together. I am not sure whether all the annotations in my App class are needed... The error is the following:</p>
  
  <p>Description:</p>
  
  <pre><code>Field employeeRepository in io.msela.springbootstarter.employee.EmployeeService 
  required a bean named 'entityManagerFactory' that could not be found.
  </code></pre>
  
  <p>Action:</p>
  
  <p>Consider defining a bean named <code>'entityManagerFactory'</code> in your configuration.</p>
  
  <p>Here is my <code>App</code> class, that runs the whole thing:</p>
  
  <pre><code>package io.msela;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.domain.EntityScan;
  import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  
  import io.msela.springbootstarter.employee.EmployeeRepository;
  
  @SpringBootApplication
  @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) //added for MySQL
  @ComponentScan({"io.msela"})
  @EntityScan("io.msela.springbootstarter")
  @EnableJpaRepositories(basePackageClasses = EmployeeRepository.class)
  public class EmployeeApiDataApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(EmployeeApiDataApplication.class, args);
      }
  }
  </code></pre>
  
  <p>And here is the XML file and the properties file:</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;io.msela&lt;/groupId&gt;
      &lt;artifactId&gt;course-api-data&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;course-api-data&lt;/name&gt;
      &lt;description&gt;Course API with Spring Data&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.5.4.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-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&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;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;!-- &lt;dependency&gt;
              &lt;groupId&gt;org.apache.derby&lt;/groupId&gt;
              &lt;artifactId&gt;derby&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt; --&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&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;/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>And properies:</p>
  
  <pre><code>spring.jpa.hibernate.ddl-auto=create-drop
  spring.datasource.url=jdbc:mysql://localhost:3306/db_example
  spring.datasource.username=springuser
  spring.datasource.password=ThePassword
  spring.jpa.database-platform = org.hiberante.dialetct.MySQLSDialect
  spring.datasource.driver-class-name = com.mysql.jdbc.Driver
  </code></pre>
  
  <p>Where should the entityManager be? And how should I make it considering my project is very simple for now (has a service, control, employee and app classes)</p>