Skip to content

Commit c56b3ba

Browse files
committedJun 30, 2022
push Dependency Injection
1 parent e287b7a commit c56b3ba

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
 

‎src/main/java/com/example/postgresql/student/Student.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void setAge(Integer age) {
7070

7171
@Override
7272
public String toString() {
73-
return "Student{" +
73+
return "Student {" +
7474
"id=" + id +
7575
", name='" + name + '\'' +
7676
", email='" + email + '\'' +
@@ -79,3 +79,4 @@ public String toString() {
7979
'}';
8080
}
8181
}
82+

‎src/main/java/com/example/postgresql/student/StudentController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.example.postgresql.student;
22

3+
import org.springframework.beans.factory.annotation.Autowired;
34
import org.springframework.web.bind.annotation.GetMapping;
45
import org.springframework.web.bind.annotation.RequestMapping;
56
import org.springframework.web.bind.annotation.RestController;
@@ -13,6 +14,7 @@ public class StudentController {
1314

1415
private final StudentService studentService;
1516

17+
@Autowired
1618
public StudentController(StudentService studentService) {
1719
this.studentService = studentService;
1820
}

‎src/main/java/com/example/postgresql/student/StudentService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.example.postgresql.student;
22

3+
import org.springframework.stereotype.Component;
4+
import org.springframework.stereotype.Service;
5+
36
import java.time.LocalDate;
47
import java.time.Month;
58
import java.util.List;
69

10+
@Service
711
public class StudentService {
812

913

0 commit comments

Comments
 (0)