'Error creating bean with name 'studentController'

I'm working on a project in spring boot using mysql and jdbc. I just trying to to a signup option and then displaying all students page. I looked on everywhere here to solve my problem but no matter what I do, I always get the same error:

UnsatisfiedDependencyExepption Error creating bean with name 'studentController'

here is my code:

student model:

@Component("student")
public class Student {

    public Student() {}

    private String userName;
    private String studentName;
    private String password;
    private String city;
    private String location;
    private String phoneNum;
    private String gender;
    
    // getter and setters and constructors
    
 }

student controller:

@RestController
@RequestMapping("/students")
public class StudentController {

    ArrayList<Student> studentList;
    Student student;

    @Autowired
    private StudentRepository studentRepo;

    public StudentController(StudentRepository studentRepo) {
        this.studentRepo = studentRepo;
    }

    @GetMapping("/signup")
    public String showSignUpPage(Student student){
        return "add-student";
    }

    @GetMapping("/addStudent")
    public String addStudent(@Valid Student student, BindingResult result) throws Exception {
        if(result.hasErrors())
            return "add-student";

        // testing
        student.setStudentName("Harry Potter");
        student.setPassword("1234");

        studentRepo.addStudent(student);
        return "redirect:/index";
    }

    @GetMapping("/index")
    public String showUserList() throws Exception {
        studentList = studentRepo.getStudents();
        return "index";
    }



}

Student Repository:

@Repository
public class StudentRepository  {

    private PreparedStatement preparedStatement = null;
    private ResultSet resultSet = null;
    private DbConnection dbCon;

    public StudentRepository() throws Exception {
        dbCon = new DbConnection();
    }
    
    //functions that go to the DB, using JCBC and mysql
}

index.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:switch="${studentList}">
    <h2 th:case="null">No students found</h2>
    <div th:case="*">
        <h2>Students</h2>
        <table>
            <thead>
            <tr>
                <th>Username</th>
                <th>Student Name</th>
                <th>City</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="student : ${studentList}">
                <td th:text="${student.username}"></td>
                <td th:text="${student.studentName}"></td>
                <td th:text="${student.city}"></td>
            </tr>
            </tbody>
        </table>
    </div>
    <p><a href="/signup">Add a new Student</a></p>
</div>
</body>
</html>

add-student.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="#" th:action="@{/addStudent}" th:object="${student}" method="post">
    <label for="name">Username</label>
    <input type="text" th:field="*{username}" id="name" placeholder="username">
    <span th:if="${#fields.hasErrors('username')}" th:errors="*{username}"></span>
    <input type="submit" value="Add Student">
</form>
</body>
</html>

pom.xml:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source