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 @@ -12,10 +12,7 @@ public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Spring6DiApplication.class, args);

MyController controller = ctx.getBean(MyController.class);

System.out.println("In Main Method");

System.out.println(controller.sayHello());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
*/
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,16 +9,13 @@
*/
@Controller
public class MyController {

private final GreetingService greetingService;

public MyController() {
this.greetingService = new GreetingServiceImpl();
}

public String sayHello(){
System.out.println("I'm in the controller");

return greetingService.sayGreeting();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
* Created by jt, Spring Framework Guru.
*/
public class PropertyInjectedController {

GreetingService greetingService;

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
*/
public class SetterInjectedController {
private GreetingService greetingService;

public void setGreetingService(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 @@ -4,6 +4,5 @@
* Created by jt, Spring Framework Guru.
*/
public interface GreetingService {

String sayGreeting();
}