Skip to Content
Suffering builds character

5.ApplicationContext

1. ApplicationContext

Spring Container를 구성하기 위해 사용되는 인터페이스,
org.springframework.context.*.jar 모듈에서 제공

이렇게 구성된 스프링 컨테이너를 통해 애플리케이션의 동작에 필요한 스프링 빈을 주입받을 수 있음

2. ApplicationContext 인터페이스 구현체

ApplicationContext는 BeanFactory를 확장(extends)한 인터페이스로 다음과 같은 위계를 가지고 있음

Several implementations of the ApplicationContext interface are part of core Spring. In stand-alone applications, it is common to create an instance of AnnotationConfigApplicationContext or ClassPathXmlApplicationContext.

→ ApplicationContext 인터페이스를 구현한 구현체들 중에서 주로 사용되는 클래스는 다음과 같음

2-1. ClassPathXmlApplicationContext

.XML 설정 파일 기반으로 스프링 컨테이너를 구성할 때 사용되는 클래스

2-2. AnnotationConfigApplicationContext

.XML 설정 파일의 의존도를 줄이고, Annotation 문법 기반으로 스프링 컨테이너를 구성할 때 사용되는 클래스

💡
Tip

Java 파일 기반으로 컨테이너 구성하기

AnnotationConfigApplicationContext는 .XML 파일이 아닌 .java 파일을 기반으로 Java 코드 레벨에서 컨테이너를 구성하는 방법도 제공함

Last updated on