Spring/Spring framework

XML 설정, bean, component-scan

hoonssss 2023. 9. 13. 21:29
반응형
SMALL

package com.in28munutes.learnspringframework.examples.h1;

import java.util.Arrays;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.in28munutes.learnspringframework.game.GameRunner;


public class XmlConfigurationContextLauncherApplication {
	public static void main(String[] args) {
		
		try(var context = new ClassPathXmlApplicationContext("contextConfiguration.xml")){
			
			Arrays.stream(context.getBeanDefinitionNames()).forEach(System.out::println);
			
			System.out.println(context.getBean("name"));
			
			System.out.println(context.getBean("age"));
			
			context.getBean(GameRunner.class).run();
		}
	}
}

name

age

depInjdectionLauncherApplication

gameRunner

marioGame

superContraGame

packmangame

org.springframework.context.annotation.internalConfigurationAnnotationProcessor

org.springframework.context.annotation.internalAutowiredAnnotationProcessor

org.springframework.context.annotation.internalCommonAnnotationProcessor

org.springframework.context.event.internalEventListenerProcessor

org.springframework.context.event.internalEventListenerFactory

MarioGame

Ranga

35

gamge on : com.in28munutes.learnspringframework.game.MarioGame@53de625d

Jump

Go into a hole

Go back

Acc

반응형
LIST

'Spring > Spring framework' 카테고리의 다른 글

Spring framework  (0) 2023.09.11
Java Bean, POJO, Spring Bean  (0) 2023.09.10
@Configuration, @Bean, @Primary, @Qualifier, @ComponentScan, 호출  (0) 2023.09.10
Spring 전체구조  (0) 2023.08.26
Spring Stereotype Annotations  (0) 2023.08.26