title: Field jdbcTemplate required a bean of type 'org.springframework.jdbc.core.JdbcTemplate' that could not be found
body: <p>I made this simple application to connect to the MySQL database and I'm getting this error: </p>
  
  <blockquote>
    <p>org.springframework.jdbc.core.JdbcTemplate</p>
  </blockquote>
  
  <p>In my configuration <code>(com.kubamadry.dao.MySqlStudentDao)</code>:</p>
  
  <pre><code>*****************************
  APPLICATION FAILED TO START
  *****************************
  
  Description:
  
  Field jdbcTemplate in com.kubamadry.dao.MySqlStudentDao required a bean of type 'org.springframework.jdbc.core.JdbcTemplate' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'org.springframework.jdbc.core.JdbcTemplate' in your configuration.
  
  Disconnected from the target VM, address: '127.0.0.1:49838', transport: 'socket'
  
  Process finished with exit code 1
  </code></pre>
  
  <p>The project structure:</p>
  
  <p><a href="https://i.stack.imgur.com/Mu9IO.png" rel="noreferrer">Image</a></p>
  
  <p><strong>Classes</strong></p>
  
  <p><strong>Main</strong> </p>
  
  <pre><code>package com.kubamadry;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  @SpringBootApplication
  public class Main {
      public static void main(String args[]) {
          SpringApplication.run(Main.class, args);
      }
  }
  </code></pre>
  
  <p><strong>Student</strong> </p>
  
  <pre><code>package com.kubamadry.entity;
  
  public class Student {
      private int id;
      private String name;
      private String course;
  }
  //Constructor, getters and setters
  </code></pre>
  
  <p><strong>StudentController</strong> </p>
  
  <pre><code>package com.kubamadry.controller;
  
  import com.kubamadry.entity.Student;
  import com.kubamadry.service.StudentService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.MediaType;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.Collection;
  
  @RestController
  @RequestMapping("/students")
  public class StudentController {
  
      @Autowired
      private StudentService studentService;
  
      @RequestMapping(method = RequestMethod.GET)
      public Collection&lt;Student&gt; getAllStudents() {
          return studentService.getAllStudents();
      }
  
      @RequestMapping(value = "/{id}", method = RequestMethod.GET)
      public Student getStudentById(@PathVariable int id) {
          return studentService.getStudentById(id);
      }
  
      @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
      public void deleteStudentById(@PathVariable int id) {
          studentService.deleteStudentById(id);
      }
  
      @RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
      public void updateStudent(@RequestBody Student student) {
          studentService.updateStudent(student);
      }
  
      @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
      public void addStudent(@RequestBody Student student) {
          studentService.addStudent(student);
      }
  }
  </code></pre>
  
  <p><strong>MySqlStudentDao</strong> </p>
  
  <pre><code>package com.kubamadry.dao;
  
  import com.kubamadry.entity.Student;
  import org.springframework.beans.factory.annotation.Autowired;
  
  import org.springframework.jdbc.core.RowMapper;
  import org.springframework.stereotype.Repository;
  import org.springframework.jdbc.core.JdbcTemplate;
  
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.Collection;
  import java.util.List;
  
  @Repository("mysql")
  public class MySqlStudentDao implements StudentDao {
  
      @Autowired
      private JdbcTemplate jdbcTemplate;
  
      @Override
      public Collection&lt;Student&gt; getAllStudents() {
          final String sql = "SELECT * FROM students";
          List&lt;Student&gt; students = jdbcTemplate.query(sql, new RowMapper&lt;Student&gt;() {
              @Override
              public Student mapRow(ResultSet resultSet, int i) throws SQLException {
                  Student student = new Student();
                  student.setId(resultSet.getInt("id"));
                  student.setName(resultSet.getString("name"));
                  student.setCourse(resultSet.getString("course"));
                  return student;
              }
          });
          return students;
      }
  
      @Override
      public Student getStudentById(int id) {
          return null;
      }
  
      @Override
      public void deleteStudentById(int id) {
           //
      }
  
      @Override
      public void updateStudent(Student student) {
           //
      }
  
      @Override
      public void addStudent(Student student) {
           //
      }
  }
  </code></pre>
  
  <p><strong>application.properties</strong></p>
  
  <pre><code>spring.datasource.url=jdbc:mysql://localhost/students
  spring.datasource.username=root
  spring.datasource.password=password123
  </code></pre>
  
  <p><strong>pom.xml</strong></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.kubamadry&lt;/groupId&gt;
      &lt;artifactId&gt;workingProject&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&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;2.0.3.RELEASE&lt;/version&gt;
      &lt;/parent&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;!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;6.0.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
              &lt;version&gt;4.3.4.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&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>Please help me with this problem.</p>