목록2023/05/04 (2)
Rootable의 개발일기

📌 DI 컨테이너에 등록된 모든 빈 조회 - getBeanDefinitionNames() : 스프링에 등록된 모든 빈 이름 조회 - getBean(이름, 타입) or getBean(타입) : Bean 이름으로 Bean 객체(인스턴스) 조회 @Test @DisplayName("모든 빈 출력하기") public void findAllBean() throws Exception { String[] beanDefinitionNames = ac.getBeanDefinitionNames(); for (String beanDefinitionName : beanDefinitionNames) { Object bean = ac.getBean(beanDefinitionName); System.out.println("name=..

1. 스프링 컨테이너를 생성한다. 스프링 컨테이너를 생성할 때는 @Configuration 애노테이션을 붙인 설정(구성) 파일을 지정해야 한다. - key: 빈 이름 - value: 빈 객체 ApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class); 2. 스프링 빈 등록 스프링 컨테이너는 파라미터로 넘어 온 설정 클래스 정보를 사용해서 스프링 빈을 등록한다. - 메서드 명 : Bean 이름 (직접 부여 가능 -> @Bean(name = "memberService2")) - 반환 객체: Bean 객체 스프링 컨테이너는 설정 파일에 대해 자바, XML 형식을 모두 지원한다. 이것은 BeanDef..