Spring Boot - Inversion of Control and Dependency Injection
Given the code below, what will be the output when the
printMessage method is called?\@Component
public class Printer {
private final MessageService service;
public Printer(MessageService service) {
this.service = service;
}
public void printMessage() {
System.out.println(service.getMessage());
}
}
\@Component
public class MessageService {
public String getMessage() {
return "Hello Spring!";
}
}