Skip to content

[21기_오지현] spring tutorial 미션 제출합니다. #5

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

Open
wants to merge 4 commits into
base: wlqgkrry
Choose a base branch
from

Conversation

wlqgkrry
Copy link

@wlqgkrry wlqgkrry commented Mar 14, 2025

1. pr 내용 요약
spring tutorial 미션 수행 후, 알게 된 spring 이론 정리


2. 자세한 내용

  1. spring의 개념, Bean에 대한 설명
  2. spring 어노테이션
  3. 단위 테스트 vs 통합 테스트

updating the explaination of spring tutorials
updating the lines
adding my think after studying spring.
@WithFortuna
Copy link

우선 1주차 과제 고생하셨습니다!


## Spring이란?
- 개발 초기에 개발자가 설정하고 관리해야 하는 대부분의 요소
(= MVC 계층 구조, 클래스 생성자, 그 외 각 계층에서 필요한 객체 생성, 소멸, 의존성 관리 등의 기능)을 자동으로 처리해주는 프레임워크.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스프링이 무엇을 자동화해주는지 예시를 들어준게 좋네요!

- Bean : Spring 컨테이너에서 생성, 관리하는 재사용 가능한 **객체**입니다.
- Bean의 특징
(1) 객체(Bean) 간 의존성(연결점)을 설정할 수 있습니다.
(2) Ioc, DI의 원리가 적용됩니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체지향 5원칙 중 IoC, DI 개념을 실제 코드와 연결지어준 부분이 좋은 것 같습니다
+
빈의 생명주기를 보면 '생성'과 '초기화'가 분리되어있는데 이렇게 분리시킨 이유로는 단일책임원칙도 있을까요? (저도 리뷰 달다가 생각나서 고민해봤습니다!)

(2) Ioc, DI의 원리가 적용됩니다.
<br>

- Bean의 라이프 사이클

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔하게 정리하셔서 보기 좋네요 :)
@PostConstruct와 @PreDestroy 어노테이션을 같이 적어줘서 이해가 편하네요.

Q. 혹시 외부 라이브러리 코드에도 콜백을 적용하고 싶을 때, 코드의 수정이 힘든 경우가 있을 텐데 이럴 때는 어떻게 처리하는게 좋을까요?
선택지: @PostConstruct&@PreDestroy VS @bean(initMehtod ="??", destroyMethod="??")
저도 아래 블로그를 참고해봤습니다( https://alkhwa-113.tistory.com/entry/%EC%8A%A4%ED%94%84%EB%A7%81-%EB%B9%88%EC%9D%98-%EC%83%9D%EB%AA%85%EC%A3%BC%EA%B8%B0%EC%99%80-%EC%B4%88%EA%B8%B0%ED%99%94-%EB%B6%84%EB%A6%AC )

@ 뒤의 단어를 통해 컴파일러의 코드 생성에 정보를 주거나, 특정 행위를 하도록 유도합니다.
주석은 프로그램에 영향을 끼치지 않지만 어노테이션은 프로그램의 동작에 다양한 영향을 줍니다.

- 어노테이션의 종류

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

### 1. 표준 어노테이션
- 자바에서 기본적으로 제공하는 어노테이션
- 종류
1) @Component : 일반적인 Bean 등록

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! 자바 표준 어노테이션과 스프링제공 어노테이션을 헷갈리신거 같습니다!(아마..?)
@OverRide는 자바 표준이 맞지만 나머지 @component,@controller 등등은 스프링에 의존하는 어노테이션으로 알고 있습니다!


## 새롭게 알게 된 점
스프링의 기본 문법과 이론에 대해 알 수 있는 기회였습니다.
이론에 집중해서 정리를 해 보았는데 다음에는 이론 + 실습을 적절히 섞어 작성해보려 합니다 : ]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정리가 깔끔하셔서 보기 좋네요 수고하셨습니다 :)

Copy link

@SeoyeonPark1223 SeoyeonPark1223 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1주차 과제 수고 많으셨습니당 :)

Comment on lines +68 to +74
### 3. 사용자 어노테이션
- 사용자가 직접 정의하여 사용하는 어노테이션
- 종류
1) @Aspect → AOP를 정의하는 클래스.
2) @Before → 메서드 실행 전에 동작합니다.
3) @After → 메서드 실행 후 동작합니다.
4) @Around → 메서드 실행 전후로 동작합니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

작성하신 어노테이션은 모두 기본으로 제공되는 어노테이션으로 알고 있습니다! 사용자 어노테이션은 작성하신대로 사용자가 @interface를 활용하여 직접 정의하는 어노테이션으로 알고 있는데 저도 다시 한번 찾아보겠습니다 :)

Copy link

@choiseoji choiseoji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1주차 과제 수고많으셨습니다!!
앞으로도 같이 파이팅해보아요 💪🔥


<br>

### 3. 사용자 어노테이션

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어노테이션의 구조를 살펴보시면 사용자 어노테이션을 어떻게 만들 수 있을지 알 수 있을거 같습니다!! 한번 보면 재밌을거 같아요~🧐

Comment on lines +22 to +26
1. @Component 또는 @Bean으로 등록된 객체가 생성됩니다.
2. 의존성 주입(@Autowired 등)
3. 초기화(Initaializing Bean, @PostConstruct -> Bean이 생성된 후 실행.)
4. 애플리케이션이 실행되면서 빈이 사용됩니다.
5. 소멸(Destroying Bean, @PreDestory -> Bean이 소멸되기 전 실행) : 애플리케이션 종료 시 정리 작업을 수행합니다.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

스프링 컨테이너에 빈을 등록하는 과정을 더 공부하면 재미있을 것 같습니다. 특히 @ComponentScan@Component 어노테이션에 대해 찾아보면 많은 정보를 얻을 수 있을 것 같습니다!

organizing the basic concepts by using Bean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants