Skip to content
Open
Show file tree
Hide file tree
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 @@ -9,11 +9,9 @@
@Controller
public class ConstructorInjectedController {
private final GreetingService greetingService;

public ConstructorInjectedController(GreetingService greetingService) {
this.greetingService = greetingService;
}

public String sayHello(){
return greetingService.sayGreeting();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
*/
@Controller
public class PropertyInjectedController {

@Autowired
GreetingService greetingService;

public String sayHello(){
return greetingService.sayGreeting();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
*/
@Controller
public class SetterInjectedController {


private GreetingService greetingService;

@Autowired
public void setGreetingService(GreetingService greetingService) {
System.out.println("SetterInjectedController.setGreetingService");
this.greetingService = greetingService;
}

public String sayHello(){
return greetingService.sayGreeting();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
* Created by jt, Spring Framework Guru.
*/
public interface GreetingService {

String sayGreeting();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

@SpringBootTest
class PropertyInjectedControllerTest {

@Autowired
PropertyInjectedController propertyInjectedController;

@Test
void sayHello() {
System.out.println(propertyInjectedController.sayHello());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

@SpringBootTest
class SetterInjectedControllerTest {

@Autowired
SetterInjectedController setterInjectedController;

@Test
void sayHello() {
System.out.println(setterInjectedController.sayHello());
Expand Down