다음 코드의 main 메서드를 실행하면 어떻게 될까? 어떤 앵무새를 소유하게 될까? 생성자 매개변수 이름이 스프링 컨텍스트 빈 이름 중 하나(parrot2)와 일치하고 스프링은 이 빈을 주입하므로 앱이 콘솔에 출력되는 앵무새 이름은 ‘Miki’가 된다(그림 3-13).
public class Main {
public static void main(String[] args) {
var context =
new AnnotationConfigApplicationContext(ProjectConfig.class);
Person p = context.getBean(Person.class);
System.out.println("Person's name: " + p.getName());
System.out.println("Person's parrot: " + p.getParrot());
}
}