title: Spring Boot - repository field required a bean named 'entityManagerFactory' that could not be found
body: <p>I am in the process of developing a Spring Boot application and came across this error when starting the server. I am not sure if I am incorrectly defining any annotations or missing any dependencies. Any help would be appreciated.</p>
  
  <p>Main class:</p>
  
  <pre><code>@SpringBootApplication
  public class FantasyManagerApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(FantasyManagerApplication.class, args);
      }
  }
  </code></pre>
  
  <p>LeagueService.java:</p>
  
  <pre><code>@Service
  public class LeagueService {
  
      @Autowired
      private LeagueRepository leagueRepository;
      @Autowired
      private PlayerRepository playerRepository;
      @Autowired
      private TeamRepository teamRepository;
  
      /**
       * Returns a list of all the leagues in the database 
       * @return List&lt;League&gt;
       */
      public List&lt;League&gt; getAllLeagues(){
          List&lt;League&gt; leagues = new ArrayList&lt;&gt;();
          leagueRepository.findAll()
          .forEach(leagues::add);
          return leagues;
      }
  
      /**
       * Find details for a particular League
       * @param leagueId
       * @return League
       */
      public League getLeagueById(long leagueId){
          return leagueRepository.findOne(leagueId);
      }
  
      /**
       * Find the leagueSettings for a particular League  
       * @param leagueId
       * @return LeagueSettings
       */
      public LeagueSettings getLeagueSettingsById(long leagueId){
          return leagueRepository.findOne(leagueId).getLeagueSettings();
      }
  
  
      /**
       * Returns a list of all the Team's in the League
       * @param leagueId
       * @return List&lt;Team&gt;
       */
      public List&lt;Team&gt; getTeamsInLeague(long leagueId){
          List&lt;Team&gt; teams = new ArrayList&lt;&gt;();
          leagueRepository.findOne(leagueId).getTeams()
          .forEach(teams::add);
          return teams;
  
      }
  
      /**
       * Returns a list of all the Player's in the League
       * @param leagueId
       * @return List&lt;Player&gt;
       */
      public List&lt;Player&gt; getPlayersInLeague(long leagueId){
          List&lt;Player&gt; players = new ArrayList&lt;&gt;();
          leagueRepository.findOne(leagueId).getPlayers()
          .forEach(players::add);
          return players;     
      }
  
      /**
       * Returns a list of all the User's in the League
       * @param leagueId
       * @return List&lt;User&gt;
       */
      public List&lt;User&gt; getUsersInLeague(long leagueId){
          List&lt;User&gt; users = new ArrayList&lt;&gt;();
          leagueRepository.findOne(leagueId).getUsers()
          .forEach(users::add);
          return users;       
      }
  
  
      /**
       * Add League to database
       * @param league
       */
      public void addLeague(League league){
          leagueRepository.save(league);
      }
  
      /**
       * Assign LeagueSettings for a League
       * @param userId
       * @param leagueSettings
       */
      public void assignLeagueSettings(long leagueId, LeagueSettings leagueSettings){
          League league = leagueRepository.findOne(leagueId);
          league.setLeagueSettings(leagueSettings);
          leagueRepository.save(league);  
      }
  
      /**
       * Assign a Player to a League and vice versa
       * @param leagueId
       * @param playerId
       */
      public void assignPlayerToLeague(long leagueId, long playerId){
          //Find the league and player from the database
          League league = leagueRepository.findOne(leagueId);
          Player player = playerRepository.findOne(playerId);
  
          //Get the players that the league already has
          List&lt;Player&gt; players = new ArrayList&lt;&gt;();
          players = league.getPlayers();
  
          //Get the leagues that the player is part of
          List&lt;League&gt; leagues = new ArrayList&lt;&gt;();
          leagues = player.getLeagues();
  
          //Assign player to this league and vice versa
          leagues.add(league);
          players.add(player);
          league.setPlayers(players);
          player.setLeagues(leagues);
  
          //Update changes in database
          playerRepository.save(player);
          leagueRepository.save(league);
      }
  
      /**
       * Assign a Team to a League and vice versa
       * @param leagueId
       * @param teamId
       */
      public void assignTeamToLeague(long leagueId, long teamId){
          //Find the league and player from the database
          League league = leagueRepository.findOne(leagueId);
          Team team = teamRepository.findOne(teamId);
  
          //Get the teams that are already in the league
          List&lt;Team&gt; teams = new ArrayList&lt;&gt;();
          teams = league.getTeams();
  
          //Assign team to this league and vice versa
          teams.add(team);
          league.setTeams(teams);
          team.setLeague(league);
  
          //Update changes in database
          teamRepository.save(team);
          leagueRepository.save(league);
      }
  
  
      /**
       * Edit the details for a particular League
       * @param league
       */
      public void updateLeague(League league, long leagueId){
          leagueRepository.save(league);
      }
  
  
      /**
       * Delete the League from the database
       * @param leagueId
       */
      public void deleteLeague(long leagueId){
          leagueRepository.delete(leagueId);
      }
  
  }
  </code></pre>
  
  <p>LeagueRepository.java</p>
  
  <pre><code>public interface LeagueRepository extends CrudRepository&lt;League, Long&gt; {
  
  }
  </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;com.dheeraj&lt;/groupId&gt;
      &lt;artifactId&gt;fantasy-manager&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;fantasy-manager&lt;/name&gt;
      &lt;description&gt;Fantasy Manager Application&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.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-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-security&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;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;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.1.4.Final&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
              &lt;version&gt;5.2.3.Final&lt;/version&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>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Field leagueRepository in com.dheeraj.service.LeagueService required a bean named 'entityManagerFactory' that could not be found.
  
  
  Action:
  
  Consider defining a bean named 'entityManagerFactory' in your configuration.
  </code></pre>