diff --git a/src/main/java/com/example/cgn221springstudent/controller/StudentController.java b/src/main/java/com/example/cgn221springstudent/controller/StudentController.java index 9ce48ed..e369f2a 100644 --- a/src/main/java/com/example/cgn221springstudent/controller/StudentController.java +++ b/src/main/java/com/example/cgn221springstudent/controller/StudentController.java @@ -3,6 +3,7 @@ import com.example.cgn221springstudent.model.Student; import com.example.cgn221springstudent.service.StudentService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Collection; @@ -12,7 +13,12 @@ @RequestMapping("student") public class StudentController { - StudentService service = new StudentService(); + private final StudentService service; + + @Autowired + public StudentController(StudentService service) { + this.service = service; + } @GetMapping public List getAllStudents() {