Spring = Container
Container
: 관리(조립)
조립할때 쓰는 클래스 이름
클래스를 모아서 관리해줌
객체 생성 에서 부터 소멸 까지 담당한다
스프링에서 지원 하는
BeanFactory CORE(DI)
- ApplicationContext ( BeanFactory 안에서 상속받음) [ DI,AOP ]
WebApplicationContext [ DI,AOP, MVC ]
- AnnotationConfigApplicationContext : 많이 사용 됨 [ DI,AOP ]
WebAnnotationCOnfigApplicationContext [ DI,AOP, MVC ]
=> XML, ANnotation 에 등록 도니 클래스를 읽어서 관리
Component
: 클래스 한개
스프링의 역할
클래스를 조립 해서 처리해줌
컴포넌트 여러개를 관리함 :
Spring Framework 구조
Configulation : XML 대신 사용 가능
싱글톤
DAO 에서 사용하면 유리
DAO 가 늘어나면 공간이 작아짐.
AO 에서 사용하면 불리 프로토타입이 적합
Annotation DL
@ Component, : 일반 클래스
@ Repository, : DAO
@ Service, : DAO 여러개 연결(조인)
@ Controller, : Model
@ RestController, : Model (restful) -> JSON
@ ControllerAdvice, : AOP
@ Configuration : 환경 설정 ( 클래스 등록)
DI
값을 넣어줄 때
@Required,자동으로 찾아줘라
@Autowired,
@PostConstruct,
@PreDestroy,
@Resource- 동일할떄 사용 ,
@PersistenceContext
@PersistenceUnit
@Autowired
얘가 뭘까요 ▲
* Spring 동작
* 1) Class.forName("Student") -> 메모리 할당
* 2) setXxx() 에 값을 채워준다
* 3) init-method 를 호출
* ===================================================
[[[ 우리가 코딩하는 부분 ]]]
* 4) 프로그래머 선택 사항
====================================================
* 5) destory-method -> 호출
'In Class' 카테고리의 다른 글
Spring @Autowired (0) | 2020.10.23 |
---|---|
Spring DI XML, Annotation 이용하는 방법 (0) | 2020.10.23 |
Spring DI (0) | 2020.10.21 |
Spring (0) | 2020.10.20 |
Spring (0) | 2020.10.19 |