< 실습 >
- 스프링 프로젝트에, 의존성을 주입할 클래스 3개 생성
@NoArgsConstructor
@Component("restaurant")
public class Restaurant {
;;
} // class
2. Chef 클래스
@NoArgsConstructor // 모든 생성자는 명시적으로 보이게 하기
@Component("Chef") // stereotype annotations
public class Chef {
;;
} // class
3. Hotel 클래스
@NoArgsConstructor
@Component("Hotel")
public class Hotel {
;;
} // class
- src 폴더 안에서 root-context.xml 파일 찾아 열기
1) 자동으로 자바빈즈 클래스를 Spring Beans Container (== Spring Context)에 빈(Bean) 등록하기- 스프링 프로젝트 root-context.xml 파일에서 Namespaces 클릭 후 context 체크 -
- xml 파일에 xmlns:context 부분 자동 생성됨
- <context:component-scan> 태그 등록
- root-context.xml 파일에서 Beans Graph 클릭 시, 의존성 주입할 콩 3개 등장
2) 수동으로 자바빈즈 클래스를 Spring Beans Container (== Spring Context)에 빈(Bean) 등록하기
- 스프링 프로젝트의 root-context.xml 파일에서, <beans> 태그 안에 <bean>태그를 이용해 등록
- 각각의 빈즈 클래스에서 @Component 어노테이션 불필요 !!!
<bean id="" class="">
<property name="" value="" />
</bean> -->
'교육과정 기록 > 💻back-end' 카테고리의 다른 글
[08.05] Quartz (0) | 2022.08.05 |
---|---|
[08.03] MyBatis 개념 정리 (0) | 2022.08.03 |
[08.02] MyBatis (0) | 2022.08.02 |
[7.28] JSP - EL (0) | 2022.07.28 |
[7.27] JSP - 액션 태그, 자바빈(JavaBeans) 규약 (0) | 2022.07.27 |