본문 바로가기
스프링

annotation

by y00ns00 2020. 5. 18.

종류가 굉장히 많다.

 

@Autowired

- 필요한 곳에 자동으로 묶기 => xml에 새로운 bean 필요 => main에 factory도 바꿔주어야함

<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"></bean>
	public static void main(String[] args) {
		
//		BeanFactory factory = 
//				new XmlBeanFactory(new FileSystemResource("src/app.xml"));
		
		ApplicationContext context = 
				new ClassPathXmlApplicationContext("app.xml");
		
		
		Greetingimple gr = context.getBean("gi", Greetingimple.class);
		

		gr.printMsg();
	}

 

의존 자동 설정
@AutoWired : 스프링전용 - 연결 : 타입에 맞춰서 연결
@Injection : 자바에서 지원 - 연결 : 타입에 뭦춰서 연결
@Resource  : 자바에서 지원 - 연결 : 이름으로 연결

'스프링' 카테고리의 다른 글

spring websocket + stomp  (0) 2020.06.03
AOP 관점 지향 프로그래밍  (0) 2020.05.20
자바 jdbc 스프링 DB 접근  (0) 2020.05.19
maven  (0) 2020.05.18
스프링 정리  (0) 2020.05.15

댓글