본문 바로가기
programming/web

[spring]autowire, qualifier

by 힐무새 2017. 6. 8.

각 자바에서 autowire 설정

  • 조립기 선언
    <context:annotation-config/>
  • 각 클래스에서 autowire 및 annotation을 설정 처리..




@Qualifier

  • @Autowired로 설정된 객체가 두가지 이상 type이 할당될 경우에 에러가 발생합니다
    - 할당 할 수 있는 객체를 선택해야 할 필요가 있을 때 id값을 @Qualifier("bean id")을 선언한다
  • @Autowired에서 해당 객체가 메모리로 할당이 안될 수도 있을 때, 반드시 할당해야 하는 경우에는 에러발생. 이를 방지하기 위해 필수는 아니라는 옵션 설정으로 에러 방지
    - @Autowired(required=false)


'programming > web' 카테고리의 다른 글

[spring]동적 SQL  (0) 2017.06.13
[spring]mybatis 연결  (0) 2017.06.08
[spring]ViewResolver  (0) 2017.06.07
[spring]ModelAndView, redirect, forward, session  (0) 2017.06.07
스프링 프레임워크  (0) 2017.05.31