-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[21기_서채연] spring tutorial 미션 제출합니다. #14
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
첫 과제 너무 수고 많으셨습니다!!!
열심히 정리하신게 눈에 보이네요! 앞으로 함께 열심히 공부해보아요!~!
즉, 스프링 컨테이너는 내부에 존재하는 빈의 생명주기를 관리(빈의 생성, 관리, 제거 등)하며, 생성된 빈에게 추가적인 기능을 제공하는 것. | ||
|
||
#### 🔹종류 | ||
`Beanfactory`와 `ApplicationContext` 두 종류의 인터페이스로 구현 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BeanFactory는 빈을 생성하고 관계를 설정하는 IoC의 기본 기능에 초점을 맞춘 것이고, ApplicationContext는 별도의 정보를 참고해서 빈의 생성, 관계 설정 등의 제어를 총괄하는 것에 초점을 맞춘 것이라고 이해하면 되겠네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 저도 그렇게 이해했습니다!
- 빈을 등록, 생성, 조회 등 빈을 관리하는 역할 | ||
|
||
(2)`ApplicationContext` | ||
- BeanFactory의 기능을 상속받으므로, 빈을 관리하고 검색하는 기능 뿐만 아니라 그 외 부가 기능을 제공함 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
부가 기능 4개는 각각 어떤 기능인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 국제화 기능
- 환경 변수
- 애플리케이션 이벤트
- 편리한 리소스 조회
4가지 입니다!
#### 🔹BeanFactory VS ApplicaionContext | ||
`ApplicaitonContext`가 `BeanFactory`의 기능을 물려 받아 빈을 관리하는 기능은 같다. 그러나 `ApplicationContext`가 더 많은 부가적인 기능을 가지고 있다. | ||
또한 빈 관리의 기능에서도 `BeanFactory`는 처음으로 getBean() 메소드가 호출된 시점에서 해당 빈을 생성하고, | ||
`ApplicationContext`는 Context 초기화 시점에 모든 싱글톤 빈을 미리 로드한 후 애플리케이션 가동 후에는 빈을 지연없이 받을 수 있다. | ||
|
||
따라서 주로 개발에서는 `ApplicationContext`을 주로 사용한다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BeanFactory는 Lazy-loading 방식이기에 빈 로딩을 요청 받는 시점에 인스턴스를 만들고 로딩을 하고 ApplicationContext는 pre-loading 방식이군요!
자주 사용되지 않는 빈을 Pre-loading 하는 것이 좋은 방식일까요??
ApplicationContext에서도 Lazy Loading 사용이 가능할까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분에 대해서 조금 더 깊게 고민해봐야할 것 같습니다..!ㅠㅠ
2. 스프링 빈 인스턴스 생성 | ||
3. 의존성 주입 | ||
4. 초기화 콜백 : 빈이 생성되고, 빈의 의존관계 주입이 완료된 후 호출 | ||
5. 사용 | ||
6. 소멸전 콜백 : 빈이 소멸되기 직전 호출 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
생성자 주입을 한다면 빈 생성부터 의존관계 주입, 초기화 콜백까지 동시에 진행가능해 라이프 사이클을 압축시킬 수 있을 거 같은데 왜 그러지 않는걸까요? 각 단계의 무게와 책임에 대해서도 한번 생각해보면 좋을 거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
각 단계의 동작 이유?에 대해서 더 조사가 필요할 것 같습니다!
#### 🔹동작 원리 | ||
어노테이션은 `리플렉션(Reflection)`을 활용해서 동작한다. | ||
즉, 런타임(실행 중)에 클래스나 메서드의 정보를 읽어와서 특정 로직을 수행한다. <br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어노테이션을 커스텀할 수 있다는 것도 아셨나요?
사용자 정의 어노테이션의 구조를 확인해본다면 다른 어노테이션의 구현부를 이해하는데 도움이 될 거 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
자료조사하면서 커스텀 어노테이션을 봤습니다ㅎㅎ 다른 어노테이션을 이해하는데 확실히 좋겠네요!
스프링은 `컴포넌트 스캔(Component Scan)`과정을 통해 빈으로 등록한다. <br> | ||
<span style="color: yellowgreen">*컴포넌트 스캔 : 스프링 빈으로 등록될 클래스패스를 스캔하여 빈으로 등록하는 과정</span> <br> | ||
1. 설정정보 클래스에 `@ComponentScan` 어노테이션을 추가해준다. | ||
2. 스프링 빈으로 등록할 클래스에 `@Component` 어노테이션을 추가하여 @ComponentScan의 대상이 되도록 지정하고 스프링 빈으로 등록해준다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@component외에 @componentscan의 대상이 되는 어노테이션들이 있을까요? 이들은 왜 스캔의 대상이 될까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@service, @controller 역시 스캔의 대상이됩니다. 모두 @component를 메타 어노테이션으로 포함하고 있기 때문입니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1주차 과제 수고 많으셨습니당 :)
#### 🔹BeanFactory VS ApplicaionContext | ||
`ApplicaitonContext`가 `BeanFactory`의 기능을 물려 받아 빈을 관리하는 기능은 같다. 그러나 `ApplicationContext`가 더 많은 부가적인 기능을 가지고 있다. | ||
또한 빈 관리의 기능에서도 `BeanFactory`는 처음으로 getBean() 메소드가 호출된 시점에서 해당 빈을 생성하고, | ||
`ApplicationContext`는 Context 초기화 시점에 모든 싱글톤 빈을 미리 로드한 후 애플리케이션 가동 후에는 빈을 지연없이 받을 수 있다. | ||
|
||
따라서 주로 개발에서는 `ApplicationContext`을 주로 사용한다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스프링 빈 링크를 참고하면 BeanFactory와 ApplicationContext의 관계를 구조적으로도 이해하기 좋을 것 같습니다 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
남겨주신 링크에 설명이 꼼꼼히 되어있는 것 같습니다ㅎㅎ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1주차 과제 고생하셨습니다 👍
**Spring** : 자바 엔터프라이즈 개발을 편하게 해주는 오픈소스 경량급 애플리케이션 프레임워크 <br> | ||
**Spring의 특징** : 자바 객체를 직접 스프링 안에서 관리, 객체의 생명 주기를 관리, <span style="color: yellowgreen">*스프링 컨테이너</span>에서 필요한 객체를 가져와 사용 <br> | ||
**POJO** : Getter, Setter로 구성된 가장 순수한 형태의 기본 클래스, 객체지향적인 원리에 충실하면서, 특정 프레임워크나 라이브러리의 특정 기능에 종속되지 않고, 필요에 따라 재활용될 수 있는 방식으로 설계된 오브젝트 <br> | ||
**스프링 삼각형** : POJO는 IoC/DI, AOP, PSA를 통해서 달성 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스프링 삼각형의 구성 요소(IoC/DI, AOP, PSA)간
어떤 관계성이 있어서 삼각형으로 묶였는지의 정보도 추가해주시면 좋을 것 같습니다. : ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인 결과,
- IoC/DI가 기반이 되어 AOP와 PSA가 동작함.
- AOP는 IoC/DI를 활용하여 공통 기능을 빈으로 관리하고 적용함.
- PSA는 AOP와 IoC/DI를 활용하여 기술 독립적인 기능을 제공함.
세 요소가 유기적으로 결합하여 삼가갛여으로 표현하는 것을 알 수 있었습니다!
또한 빈 관리의 기능에서도 `BeanFactory`는 처음으로 getBean() 메소드가 호출된 시점에서 해당 빈을 생성하고, | ||
`ApplicationContext`는 Context 초기화 시점에 모든 싱글톤 빈을 미리 로드한 후 애플리케이션 가동 후에는 빈을 지연없이 받을 수 있다. | ||
|
||
따라서 주로 개발에서는 `ApplicationContext`을 주로 사용한다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 분들께서도 많은 의견을 주셨지만 저도 궁금해서 하나의 의견을 추가합니다!
주로 개발에서는 applicationContext를 사용한다고 하셨는데
만약 구태여 BeanFactory를 사용해야 한다면, 그 경우가 어떤 경우인지도 알아보면 좋을 것 같습니다 : ]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
말씀대로 한번 찾아보면 학습에 더 도움이 될 것 같네요 ㅎㅎ
1. 설정정보 클래스에 `@ComponentScan` 어노테이션을 추가해준다. | ||
2. 스프링 빈으로 등록할 클래스에 `@Component` 어노테이션을 추가하여 @ComponentScan의 대상이 되도록 지정하고 스프링 빈으로 등록해준다. | ||
3. 스프링 빈으로 등록할 때 필요한 DI는 `@Autowired`를 이용해 처리한다. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어노테이션의 종류도 다양한 것으로 보였는데, 어떤 종류가 있는지도 알아보신다면
사용 시 효율성이 극대화 되리라 생각합니다 : >
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
자주 쓰이는 어노테이션들을 미리 정리해두면 좋을 것 같아요ㅎㅎ
- 생성자 주입은 애플리케이션 구동 시점, 객체의 생성 시점에 에러가 발생한다. | ||
3. 테스트 용이 | ||
- 단위 테스트를 진행할 때 순수 자바 코드로 테스트가 가능하다. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우선 1주차 과제 정말 고생하셨습니다 👍
- 정리하실 때 가독성을 위해 노란색으로 표시하시는 등 많은 노력을 하신 것 같습니다.
- 주제별로 깔끔하게 정리하셔서 읽기에 편했습니다.
- 각 주제 별 참고한 자료도 올려주셔서 한 번씩 읽어본게 저에게 도움이 되었습니다.
- 대부분의 내용을 사용법과 정의에 대해 명료하게 작성하셨는데, 그렇게 작용하는 이유도 함께 적어주시면 원리 파악에 더 도움이 될 것 같습니다. (개인적 의견)
No description provided.