Skip to content
Open

DI #1

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Student> getAllStudents() {
Expand Down