main() 메서드가 구성 클래스에서 빈 구성을 읽어 들일 수 있도록 ClassPathXmlApplication Context 대신 다른 ApplicationContext 구현체로 코드를 수정해야 합니다. 이 역할을 담당하는 클래스는 AnnotationConfigApplicationContext입니다.
예제 2-16 스프링의 AnnotationConfigApplicationContext 사용하기([[hello-world]] HelloWorldSpringAnnotated.java)
package com.apress.prospring5.ch2.annotated; import com.apress.prospring5.ch2.decoupled.MessageRenderer; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class HelloWorldSpringAnnotated { public static void main(String... args) { ApplicationContext ctx = new AnnotationConfigApplicationContext (HelloWorldConfiguration.class); MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class); mr.render(); } }